There is no need to animate your cells though because the number of rows will always stay the same. Every book has 1 title, 1 author, and 1 publisher. There will always be an equal amount of titles, authors, and publishers.
You might have already done some of these steps but I'm going to include all of them to be thorough. Create a UISegmentedControl ivar. Setup the UISegmentedControl ivar. Then in your cellForRowAtIndexPath, check the segmented control's selected segment index. Then depending on the value, set the cell's label's text accordingly.
You shouldn't be adding rows in cellForRowAtIndexPath.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
There is no need to animate your cells though because the number of rows will always stay the same. Every book has 1 title, 1 author, and 1 publisher. There will always be an equal amount of titles, authors, and publishers.
You might have already done some of these steps but I'm going to include all of them to be thorough. Create a UISegmentedControl ivar. Setup the UISegmentedControl ivar. Then in your cellForRowAtIndexPath, check the segmented control's selected segment index. Then depending on the value, set the cell's label's text accordingly.
You shouldn't be adding rows in cellForRowAtIndexPath.
i do this :
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell
book *bok = (book *)[self.booktable objectAtIndex:indexPath.row];
switch (segControl.selectedSegmentIndex)
{
case 0:
cell.textLabel.text =bok.book_title;
break;
case 1:
cell.textLabel.text =bok.author_name;
break;
case 2:
cell.textLabel.text =bok.pub_name;
break;
default:
break;
}
return cell;
}