Tab bar, reload every time tab is pressed

前端 未结 7 728
梦毁少年i
梦毁少年i 2021-01-13 01:17

I am creating an app in which I have five tabs. I need to reload each controller every time when tab is pressed.

7条回答
  •  深忆病人
    2021-01-13 02:06

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
        //other codes
    
        [self.tabBarController setDelegate:self]
    
        //other codes
        }
    
    // UITabBarControllerDelegate method.
    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    {
        if ([viewController respondsToSelector:@selector(reloadDataTemp)]) {
            [(YourViewController *)viewController reloadData];
        }
    }
    

提交回复
热议问题