Мое решение:
Я создаю 1 NSArray*
, чтобы содержать текущее имя меню: menuDataSource
. menuDataSource
содержит только текущее меню.
-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
return [menuDataSource objectAtIndex:0];
}
Когда пользователь меняет меню, я воссоздаю menuDataSource с новым меню:
[internalTableView beginUpdates];
currentHorizonMenu = [[self.reusableCells objectAtIndex:menuIndex]retain];
menuDataSource = [NSMutableArray array];
[internalTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[menuDataSource addObject:currentHorizonMenu];
[internalTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationBottom];
[internalTableView endUpdates];
self.reusableCells
is NSArray*
содержит все меню