how to get the event that switch tab menu on iphone

Implement UITabBarControllerDelegate e.g. in your app delegate’s applicationDidFinishLaunching – (void)applicationDidFinishLaunching:(UIApplication *)application { tabBarController.delegate = self; [window addSubview:tabBarController.view]; } Then implement either: – (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController; – (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController; The first method is called before the view switch and gives you a chance to ‘veto’ the view switch by returning NO The second … Read more

UITabBar(Controller) – Get index of tapped?

The answer depends on whether or not the UITabBar is managed by a UITabBarController or not. Case 1 – UITabBar is already handled by a UITabBarController Implement the UITabBarControllerDelegate protocol. Specifically the tabBarContoller:didSelectViewController: method. Set an instance of your class that implements the protocol as the delegate of the UITabBarController. – (void)tabBarController:(UITabBarController *)theTabBarController didSelectViewController:(UIViewController *)viewController … Read more