Ios UITableViewController重新加载数据不工作
我有一个UITableViewController,用于从数据库获取数据。 我想在每次数据变化时显示它Ios UITableViewController重新加载数据不工作,ios,objective-c,Ios,Objective C,我有一个UITableViewController,用于从数据库获取数据。 我想在每次数据变化时显示它 - (void)setMyArray:(NSArray *)myArray{ if (_myArray!=myArray) { _myArray=myArray; [self.tableView reloadData]; } } 通过调试,我注意到当调用重载数据时,numberOfRowsInSection:(NSInteger)部分 被称为。
- (void)setMyArray:(NSArray *)myArray{
if (_myArray!=myArray) {
_myArray=myArray;
[self.tableView reloadData];
}
}
通过调试,我注意到当调用重载数据时,numberOfRowsInSection:(NSInteger)部分
被称为。
但是CellForRowatinex没有被触动。
如果移动tableview,则调用CellForRowatinex。
如何以编程方式重新加载数据?我会检查两件事,您是否正确初始化了
\u myArray
,以及通过执行NSLog返回的numberOfRowsInSection
值<仅当numberOfRowsInSection
大于0时,才会调用code>cellforrowatinexpath 这是正确的方法,尽管使用\u myArray=[myArray copy]
更为正确。问题一定出在其他地方。numberOfRowsInsection是否返回大于0的行数?非常确定在上面的评论中没有人提到初始化_myArray的问题,很可能就是这个问题。