Rob*_*Rob 1 uitableview reloaddata ios
每当用户重新进入我的iphone应用程序时,我一直在尝试重新加载表格.表格的所有信息都是正确和正确的.该表正在输入正确的数据源和委托,我打印的值是我想要的,但在视觉上表格不会在视觉上重新加载.我的调用在appWillEnterForeground中,并且调用viewWillLoad.
您不应该像上面的评论中描述的那样触发viewDidLoad.viewDidLoad是CocoaTouch框架在适当的时候调用的一种特殊方法.它不应该由您的代码直接调用.
相反,您可以使用通知来完成同样的事情.这是你正在做的事情的正确方法:
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Fire a notification to let all views know that our app entered foreground.
[[NSNotificationCenter defaultCenter] postNotificationName:@"EnteredForeground"
object:nil];
}
Run Code Online (Sandbox Code Playgroud)
处理特定ViewController中的通知:
- (void)viewDidLoad {
...
[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(enteredForeground:)
name:@"EnteredForeground"
object:nil];
}
// Handle the notification in your ViewController:
- (void)enteredForeground:(id)object {
// Reload the tableview
[self.tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
814 次 |
| 最近记录: |