How to implement didSelectViewController

后端 未结 3 1717
难免孤独
难免孤独 2020-12-10 20:50

I want to catch the event when someone switches between tabs. I have the following two function in my appdelegate file:

- (BOOL)application:(UIApplication *         


        
3条回答
  •  旧巷少年郎
    2020-12-10 21:14

    I also struggled with this a lot but my UITabBarNavigationController is pretty far from AppDelegate to set it there, and the only way to actually make it work was to do it not in the viewDidLoad of the UITabBarController subclass itself, but in its:

    -(void)viewDidLayoutSubviews {
        [ super viewDidLayoutSubviews ];
        self.delegate = self;
    }
    

    And that solved it. Alternatively you can do it in any of the tab bar controlled viewcontrollers, but that just feels wrong.

提交回复
热议问题