iphone - UITableView numberOfRowsInSection

标签 iphone objective-c ios

我有 6 个 NSMutableArray(monday,tuesday...saturday),我将其添加到 NSMutableArray“day” 我在这个方法中做“numberOfRowsInSection”

NSArray *array = [day objectAtIndex:section];
return [array count];

所有工作,但是当我添加项目时,只有在重建项目或删除一行时我才会有项目

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:995

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.
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 (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).

如果我执行此方法,一切正常,但我需要执行第一种方法,两三行

if(section==0)
  return [monday count];
if(section==1)
  return [tuesday count];
if(section==2)
  return [wednesday count];
if(section==3)
  return [thirsday count];
if(section==4)
  return [friday count];
if(section==5)
  return [saturday count];

最佳答案

删除表格 View 单元格时,必须删除数组中的对象。 如果您删除第一行第一节的单元格,您应该:

[[day objectAtIndex:one] removeObjectAtIndex:one];

关于iphone - UITableView numberOfRowsInSection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9128977/

相关文章:

Objective-C:类似函数的宏与。方法

ios - CGAffineTransformMakeRotation 再次不起作用

objective-c - 对 ' ' 的引用是 Xcode 中的不明确错误

iOS 单元测试按钮已分配 Action

ios - 当以编程方式设置 Root View Controller 时,导航和选项卡栏丢失

iphone - 添加音频文件iPhone应用程序

ios - 用swift检查数字是否为十进制

ios - 联系选择器不工作

ios - 如何使用 PFQuery 查询与数组的精确匹配?

iphone - xcode 在 View 之间传递 3 个 nsstring 值时遇到问题