我有两个视图控制器A和B.
进入A我有一个UITableView和一个NSNotification观察者进入viewDidLoad函数 .
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshInterface) name:@"newDataAreAvailable" object:nil];
相关选择器:
-(void) refreshInterface{
[[self tableView] reloadData];
}
现在,从我的B ViewController我发布一个通知到A来重新加载我的tableview数据 .
但是 cellForRowAtIndexPath
永远不会被调用而 numberOfRowsInSection
会返回5个元素 .
为什么?
1 回答
cellForRowAtIndexPath仅在单元格可见时调用 . 如果表A不可见,则在它变得可见之前不会发生 .
您还需要确认您的通知被触发并且重新加载正在发生 .