iPhone, how'd I override a tab bar button to do other than the navigation controller in my mainWindow.xib
At the moment I have all my views specified in my mainWindow.xib file in interface builder.
So when a tab bar button is tapped it loads the correct navigation controller.
But I want to do so开发者_运维知识库mething different in code when they tap the tab bar button for one button.
How do I do that?
EDIT - Not quite working solution...
You should add a delegate to your tabBar and have it implement the method:
- (void)tabBarController:(UITabBarController *)tbc didSelectViewController:(UIViewController *)newSelection
this way, you will be able to do whatever you want to new selected view Controller and the tabBar itself.
You can use the UITabBarControllerDelegate methods to call custom code. Use shouldSelectViewController and put your custom code in there.
Also, I recommend to not put all the views in the same .xib file. Separating them inproves performance because it doesn't have to load all the objects at once.
精彩评论