HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 向UITableView添加行时的NSInternalInconsistencyException大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在向UITableView添加新行时遇到了麻烦.我在stackoverflow上读了类似的问题,谷歌搜索,…没有帮助我.

我有空的NSMutableArray * dataForList和UITableView的数据.点击屏幕后,我想添加新行.此错误显示

码:

NSArray *inserTindexPaths = [NSArray arrayWithObject: 
                             [NSIndexPath indexPathForRow:
                              [self.dataForList count] // is zero Now
                              inSection:0]];

[self.dataForList addObject:newRow];
// [self.dataForList count] is 1 Now

[self.unsignedTableView beginupdates];
[self.unsignedTableView insertRowsATindexPaths:inserTindexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.unsignedTableView endupdates]; // on this line error ocours

我错过了什么?

所有UITableView方法

- (void) tableView:(UITableView *)tableView didSELEctRowATindexPath:(NSIndexPath *) indexPath {}

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
return [self.mainController.dataForList count];
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowATindexPath:(NSIndexPath *) indexPath{
return 38.0f;
}

- (UITableViewCell *) tableView: (UITableView *) tableView
      cellForRowATindexPath: (NSIndexPath *) indexPath {
// call render method in view,it works fain
return [self.signUpToTestView renderUnsignedCell:tableView cellForRowATindexPath:indexPath];
}

解决方法

您是否在点击后根据您的数组更改了numberOfSection和numberOfRowsInSection?

return [arr count];

并尝试重新加载表格

[table reloadData];

大佬总结

以上是大佬教程为你收集整理的iphone – 向UITableView添加行时的NSInternalInconsistencyException全部内容,希望文章能够帮你解决iphone – 向UITableView添加行时的NSInternalInconsistencyException所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。