ios uiview 如何刷新_ios – 从另一个UIViewController刷新表
選項1
@類2
@property (nonatomic) BOOL shouldRefresh; // in .h file
- (void)viewWillAppear:(BOOL)animated // in .m file
{
[super viewWillAppear:animated];
if (_shouldRefresh) [self.tableView reloadData];
}
@ Class1的
// Add this in any method where you want it to refresh and push to view
ClassTwoController *viewController = [[ClassTwoController alloc] init];
[viewController setShouldRefresh:YES];
[self.navigationController pushViewController:viewController animated:YES];
*更新:
選項2
@Class 2
// Add this line in viewDidLoad in same class you want the tableView to refresh
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshTableWithNotification:) name:@"RefreshTable" object:nil];
// Add this method just beneath viewDidLoad:
- (void)refreshTableWithNotification:(NSNotification *)notification
{
[self.tableView reloadData];
}
@ Class1的
// Call this when ever you want to refresh the tableView in Class2
[[NSNotificationCenter defaultCenter] postNotificationName:@"RefreshTable" object:nil userInfo:nil];
總結
以上是生活随笔為你收集整理的ios uiview 如何刷新_ios – 从另一个UIViewController刷新表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: numpy列相加_Python数据分析入
- 下一篇: redis 正则匹配value_Redi