0
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    [[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self]; //Add nearby buttons
}

其中一个UIViewController是顺序

  1. viewDidload被叫
  2. [[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self];

而且因为通知设置是在 viewDidLoad 调用的,所以我需要先调用 viewDidLoad `

  1. -(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];
4

1 回答 1

2

将您的通知放在 ViewWillAppear ()

于 2013-03-26T04:51:05.750 回答