[英]cellForRowAtIndexPath not being called required number of times
我想要实现的功能是,首先我在UITableView
显示两行,显示完美。 然后在didSelectRowAtIndexpath:
,我在UITableView
添加了numberOfRows
,我在添加numberOfRows
和所需数据后重新加载UITableView
。
我的问题是我在numberOfRowsInSection:
传递了新的行数numberOfRowsInSection:
我已经检查过,它正确传递)但是在此之后只调用了两次cellForRowAtIndexpath:
这是之前的numberOfRows
值。
我的代码:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.currentSubCategoryRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// My code for cell construction goes here
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.arrWithAdditionalValues addObjectsFromArray:[self.dictSubCategoriesLevel3 objectForKey:[NSString stringWithFormat:@"%d",rowOpened]]];
self.currentSubCategoryRows += self.arrWithAdditionalValues.count;
[tableView reloadData];
}
可能是什么原因?
任何帮助,将不胜感激!!!
我找到了解决方案。
当我调整我UITableView
按照其数行cellForRowAtIndexPath:
这就是为什么的下一个部分UITableView
是不可见的,并为部分UITableView
这是不可见的, cellForRowAtIndexPath:
不会被调用。
对不起打扰你们。
非常感谢你的帮助!!!
cellForRowAtIndexPath:仅在绘图时需要立即调用。 您必须构建该方法,而不必控制何时调用它。
尝试在viewWillAppear
重新加载表
- (void)viewWillAppear:(BOOL)animated {
[tableview reloadData];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.