У меня есть tableView с некоторыми разделами и каждым разделом с некоторыми rows.Every строка имеет любимую кнопку. Если кнопка нажата, строка должна быть добавлена в раздел избранных. (который изначально пуст).скопировать строку в другую секцию в UITableView
Я написал некоторый код. Но проблема в том, что он работает в симуляторе iOS 5 и сбой в симуляторе iOS 6 с ошибкой обновления Invalid tableView.
Может кто-нибудь сказать мне, где проблема?
-(void)moveRowToFavourites:(id)sender{
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell *)button.superview.superview;
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
[tempArray addObject:[NSIndexPath indexPathForRow:favouritesArray.count inSection:0]];
[favouritesArray insertObject:cell.textLabel.text atIndex:favouritesArray.count];
[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:(NSArray *)tempArray withRowAnimation:UITableViewRowAnimationFade];
[[self tableView] endUpdates];
}
EDIT
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(searching){
return [self.searchResults count];
}
else{
if ([[arrayForBool objectAtIndex:section] boolValue]) {
if(section == 0){
return favouritesArray.count;
}else{
NSString* key = [self.proCategoriesArray objectAtIndex:section - 1];
NSArray *aArray = [sectionContentDict valueForKey:key];
return aArray.count;
}
}
return 1;
}
}
Описание ошибки содержит очень четкое объяснение проблемы. –
сделал ou try reloadData вместо обновлений? –
Какая ошибка? –