开发者

How to know tabbar tab was pressed?

开发者 https://www.devze.com 2022-12-30 12:26 出处:网络
I have a tabbar based app.In the app delegate, I\'ve implemented: - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{

I have a tabbar based app. In the app delegate, I've implemented:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    if([viewController isKindOfClass:[TabBNavigationController class]]){
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc postNotificationName:@"TabBClicked" 
    object:self userInfo:nil];}

and fire off a开发者_StackOverflow中文版 notification. ViewB is displayed when tabB is pressed. ViewB is inside a UINavigationController. The problem is ViewB's viewWillAppear fires before the above event. I need to know TabB was clicked before ViewB's viewWillAppear fires. Is there another way to get in front of viewWillAppear in this case?


Did you try tabBarController:shouldSelectViewController:, this method should be called before any view gets visible.

0

精彩评论

暂无评论...
验证码 换一张
取 消