別のViewControllerのページカールが閉じられた後、ViewControllerのテーブルビューをリロードするにはどうすればよいですか。
viewController1にテーブルビューがあり、viewController2へのページカールを使用したトランジションがあります。
viewController1にはtableViewがあり、ページのカールを閉じた後に再ロードする必要があります。
助けてくれてありがとう
別のViewControllerのページカールが閉じられた後、ViewControllerのテーブルビューをリロードするにはどうすればよいですか。
viewController1にテーブルビューがあり、viewController2へのページカールを使用したトランジションがあります。
viewController1にはtableViewがあり、ページのカールを閉じた後に再ロードする必要があります。
助けてくれてありがとう
Ok、
viewControllers1で、viewDidLoadに通知を登録します。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"MyNotification" object:nil];
メソッドを追加します。
- (void)handleNotification:(NSNotification*)note {
[tableView reloadData];
}
viewController2で、viewController1に移動するとき、またはテーブルをリロードするときに通知を投稿します。
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:self];
viewController1のviewWillAppear
メソッドでは、テーブルビューのメソッドを呼び出すことができますreloadData
。
viewController1の
- (void)viewDidDisappear:(BOOL)animated
{
[tableView reloadData];
}
tableViewはメンバーである必要があります。
In first viewcontoller.h put this in viewdidload
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_data) name:@"reload_data" object:nil];
-(void)handle_data
{
[yourtableview reloaddata];
}
In second viewcontroller.h
[[NSNotificationCenter defaultCenter] postNotificationName:@"reload_data" object:self];