私はいくつかのセクションといくつかの行を持つ各セクションを持つtableViewを持っています.すべての行にはお気に入りのボタンがあります.ボタンがクリックされると、行はお気に入りセクションに追加されます. (最初は空です)。
私はいくつかのコードを書きましたが、問題は iOS 5 シミュレーターで動作し、無効な tableView 更新エラーで iOS 6 シミュレーターでクラッシュすることです。
誰かが問題の場所を教えてもらえますか?
-(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];
}
編集
- (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;
}
}