【发布时间】:2014-04-26 13:14:53
【问题描述】:
我的 UITableView 的 beginupdates 和 endupdates 出现了一些问题。我想使用这个函数来为我的 tableview 设置动画,而不是使用我现在使用的 reloadData。当我使用 BeginUpdates 执行此操作并抱怨此问题时,它总是会出现问题:
'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
所以我的 numberOfRowInSection 有问题:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
int returnInt;
if (section == 0) {
if ([self datePickerIsShown]){
returnInt = 3;
}else{
returnInt = 2;
}
}else if([[[[self theNewGame] _dobbelstenen] objectAtIndex:section - 1] diceSoort] == ENUMOgen){
returnInt = 1;
}else{
returnInt = [[[[[self theNewGame] _dobbelstenen] objectAtIndex:section - 1.0] optiesDobbelsteen] count] + 1.0;
}
return returnInt;
}
我这样称呼它:
if (indexPath.section == 0 && indexPath.row == 1) {
self.datePickerIsShown = ! self.datePickerIsShown;
[tableView beginUpdates];
[tableView endUpdates];
}
有什么问题?
亲切的问候
【问题讨论】:
标签: ios objective-c uitableview