Я сделал код, чтобы показать исчезновение ячейки при нажатии на Отдел, код хорошо работает для IOS 3.0 и 4.o
код выглядит как
- (NSArray*)indexPathsInSection:(NSInteger)section {
NSMutableArray *paths = [NSMutableArray array];
NSInteger row;
for ( row = 0; row < [self numberOfRowsInSection:section]; row++ )
{
[paths addObject:[NSIndexPath indexPathForRow:row inSection:section]];
}
return [NSArray arrayWithArray:paths];
}
- (void)toggle:(BOOL*)isExpanded section:(NSInteger)section {
*isExpanded = !*isExpanded;
[Table beginUpdates];
if ( !*isExpanded )
{
NSArray *paths = [self indexPathsInSection:section];
[Table deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
}
else {
NSArray *paths = [self indexPathsInSection:section];
[Table insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight];
}
[Table endUpdates];
[Table reloadData];
}
- (NSInteger)numberOfRowsInSection:(NSInteger)section {
if(kMAX_SECTION_ROWS[section] == 0)
{
return 1;
}
else
{
return kMAX_SECTION_ROWS[section];
}
//return 0;
}
- (void)toggleSection:(id)sender {
NSLog(@"button %d is clicked.",[sender tag]);
int i = [sender tag];
if(!isSectionExpanded[i]){
NSLog(@"expanded");
hString[i].arrowImage.image = [UIImage imageNamed:@"downarrow.png"];
}
else {
NSLog(@"not expanded");
hString[i].arrowImage.image = [UIImage imageNamed:@"arrowgrean.png"];
}
[self toggle:&isSectionExpanded[i] section:i];
}
когда я запускаю код в IOS 5, он показывает мне ошибку
Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates],/SourceCache/UIKit_Sim/UIKit-1912.3/UITableViewSupport.m:386
если есть подсказка, ответьте спасибо