Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewController重新加载数据不工作_Ios_Objective C - Fatal编程技术网

Ios UITableViewController重新加载数据不工作

Ios UITableViewController重新加载数据不工作,ios,objective-c,Ios,Objective C,我有一个UITableViewController,用于从数据库获取数据。 我想在每次数据变化时显示它 - (void)setMyArray:(NSArray *)myArray{ if (_myArray!=myArray) { _myArray=myArray; [self.tableView reloadData]; } } 通过调试,我注意到当调用重载数据时,numberOfRowsInSection:(NSInteger)部分 被称为。

我有一个UITableViewController,用于从数据库获取数据。 我想在每次数据变化时显示它

- (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的问题,很可能就是这个问题。