iphone – 向UITableView添加行时的NSInternalInconsistencyException

iphone – 向UITableView添加行时的NSInternalInconsistencyException,第1张

概述我在向UITableView添加行时遇到了麻烦.我在stackoverflow上读了类似的问题,谷歌搜索,…没有帮助我. 我有空的NSMutableArray * dataForList和UITableView的数据.点击屏幕后,我想添加新行.此错误显示: * Terminating app due to uncaught exception ‘NSInternalInconsistencyEx 我在向UItableVIEw添加新行时遇到了麻烦.我在stackoverflow上读了类似的问题,谷歌搜索,…没有帮助我.

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

* Terminating app due to uncaught exception ‘NSInternalinconsistencyException’,reason: ‘attempt to insert row 0 into section 0,but there are only 0 rows in section 0 after the update’

码:

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 fainreturn [self.signUpToTestVIEw renderUnsignedCell:tableVIEw cellForRowAtIndexPath:indexPath];}
解决方法 您是否在点击后根据您的数组更改了numberOfSection和numberOfRowsInSection?

return [arr count];

并尝试重新加载表格

[table reloadData];
总结

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1081413.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存