how to get the event that switch tab menu on iphone

后端 未结 5 2322
星月不相逢
星月不相逢 2020-12-03 17:03

I\'m trying to figure out how to catch the event that controls the switch tabs on the UITabBarController. How could I accomplish this?

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 17:28

    If you are using storyboard, do this

    in didFinishLaunchingWithOptions

    UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
    [tabBar setDelegate:self];
    

    Also in AppDelegate, keep

    And then

    -(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    {
       //Write your code here
    }
    

提交回复
热议问题