-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
[[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self]; //Add nearby buttons
}
在一个UIViewController
中,这里是序列
viewDidload
被召唤[[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self];
因为在viewDidLoad中调用了通知设置,所以我需要在`
之前先调用viewDidLoad-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
`
我怎么能实现这个目标?
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(addReloadButton) name:ListOrMapAddReloadButton object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(addNearbyButton) name:ListOrMapAddNearbyButton object:nil];
答案 0 :(得分:2)
将您的通知放在ViewWillAppear()
中