0
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
[[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self]; //Add nearby buttons
}
在一个UIViewController
这里是序列为什么有时候viewDidLoad首先被调用,有时候被称为后者?
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];
我希望它是一次叫,然后在dealloc的去除。因此我把它放在viewdidload上。我认为viewdidload是一个适合dealloc的“pair”。 – 2013-03-26 04:55:55
其实'dealloc'最适合的“pair”是'init' ... – fumoboy007 2013-03-26 05:30:21