简体   繁体   English

UITableView numberOfRowsInSection

[英]UITableView numberOfRowsInSection

I have got 6 NSMutableArray(monday,tuesday...saturday) which I add to NSMutableArray "day" I doing in this method " numberOfRowsInSection " 我有6个NSMutableArray(monday,tuesday ... saturday),我将其添加到NSMutableArray“ day”中,我在此方法中执行的“ numberOfRowsInSection”

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

all work, but when I add item I have item only when I rebuild project or if I delete a row I have got error 所有的工作,但当我添加项目时,只有在重建项目或删除行时才有项目

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:995 -[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. 由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“无效的更新:第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). 更新(3)之后,现有节中包含的行数必须等于更新(3)之前该节中包含的行数,加上或减去从该节中插入或删除的行数(已插入0) ,其中1个已删除)。

if I doing this method everything works but i need doing the first method, in two-three lines 如果我执行此方法,则一切正常,但是我需要在两三行中执行第一种方法

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];

you must remove object in your array when you delete tableview cell. 删除表视图单元格时,必须删除数组中的对象。 if you remove cell at section one row one,you should: 如果您删除第一节第一行的单元格,则应该:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM