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