I am using two UItableView in my apps. I set their delegate and datasource to file’s owner.
At implementation part I have tried :
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView=tableView1)
{
return [tableArr count];
}
if (tableView=tableView2)
{
return [tableArr count];
}
}
In method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView==tableView1)
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text=[tableArr objectAtIndex:indexPath.row];
return cell;
}
if (tableView==tableView2)
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text=[tableArr objectAtIndex:indexPath.row];
return cell;
}
and
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
I also tried by calling that tableView like tableView1 & tableView2.But it shows blank table. So is it possible to to add to tableView in UIView?
As Eimantas said u should try comparing rather than assigning, try this and make sure you check the contents of the table also according to your needs in
cellForRowAtIndexPath: