Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do like this,</p> <pre><code>-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { switch (sgmtControl.selectedSegmentIndex) { case 0: return [firstName count]; break; case 1: return [middleName count]; break; case 2: return [lastName count]; break; } return 0; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section { switch (sgmtControl.selectedSegmentIndex) { case 0: return @"FirstName"; break; case 1: return @"MiddleName"; break; case 2: return @"LastName"; break; } } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *myIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myIdentifier]; } switch (sgmtControl.selectedSegmentIndex) { case 0: cell.textLabel.text =[firstName objectAtIndex:indexPath.row]; break; case 1: cell.textLabel.text = [middleName objectAtIndex:indexPath.row]; break; case 2: cell.textLabel.text = [lastName objectAtIndex:indexPath.row]; break; } return cell; } -(IBAction)changeSegement:(id)sender { if(sgmtControl.selectedSegmentIndex == 0) { tblView.hidden = NO; } else if (sgmtControl.selectedSegmentIndex == 1) { tblView.hidden = NO; } else if (sgmtControl.selectedSegmentIndex == 2) { tblView.hidden = NO; } [tblView reloadData]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload