reloadData不会调用cellforrowatindexpath
也许这是一个类似的开始,但这是事实。reloadData不会调用cellforrowatindexpath
首先抱歉,如果这是格式不正确,第一次这样做。我一直在使用stackoverflow来查找很长一段时间的帮助,这非常有帮助(谢谢大家),但这是我第一次发布自己的问题。这个问题已经被问过很多次了,但是当我调用[self.tableView reloadTable]时,方法numberOfSectionsInTableView和numberOfRowsInSection被调用,但不是cellForRowAtIndexPath。
每一个答案,当搜索一直是一个变化我看到:
- 的是的tableView
nil
-
numberOfRowsInSection
是0 - 的tableView的委托/数据源未设置。这些都不是我的情况,所以我想知道还有什么可能是错的。
但我不确定4.在错误的uiTableView上调用reloadTable。或者它是关于其他一些错误的。
现在我的APP是类似于TableView.also 的Dropbox, 第一,当我们登录到它,我们得到一个文件列表(包括目录),我说在视图的底部工具栏由[self.navigationController.view addSubview:toolBar]
,当我触摸按钮项“刷新”时,它调用[self.tableView reloadData]
并且运行良好。
其次,当我们选择一个目录,我们将得到一个新的文件目录表是由pushViewController
self.navigationController
,但是这一次,当我们触摸“刷新”,语句[self.tableView reloadData]调用numberOfSections,numberOfRows,不是的cellForRowAtIndexPath
关于为什么cellForRow不会被第二次调用的任何想法?提前致谢。
FileListViewController.h
@interface FileListViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource>
FileListViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (isDir) {
FileListViewController *fileListViewController = [[FileListViewController alloc] init];
[self.navigationController pushViewController:fileListViewController animated:YES];
}
}
- (void)refresh
{
[Utilities refresh];//Utilities is my custom class.
[self viewDidLoad];
[self.tableView reloadData];
}
我的表视图部分和行的回归数不为0
当我加入NSLog(@"Calling reloadData on %@", self.tableView);
到“刷新”:
- (void)refresh
{
[Utilities refresh];//Utilities is my custom class.
[self viewDidLoad];
NSLog(@"Calling reloadData on %@", self.tableView);
[self.tableView reloadData];
}
然后返回上调用reloadData; contentOffset:{0,0}>。委托:FileListViewController,DataSource:FileListViewController
感谢您的建议。我删除了[self viewDidLoad],我同意你的看法。但现在问题仍然存在,当我触摸目录下的“刷新”按钮时,[self.tableView reloadData]不会调用cellForRowAtIndexPath。是因为我分配一个新的tableView FileListViewController * fileListViewController = [[FileListViewController alloc] init]? – Philip
可能你没有正确连接新的tableView(数据源和委托)或手动alloc/init新的tableView,并将其分配给稍后/早期从xib启动的属性。 –