0

I have a method as below:

- (IBAction)GoToMyWebsite:(id)sender
{
    [self.window makeKeyAndVisible];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:cc.BPS_WEB_ADDRESS]];
    exit(0);
}

How can I connect this method to a tab bar item? So that when I click the specific tab bar item, this method will be executed.

Thanks

UPDATE

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSLog(@"didSelectItem: %d", item.tag); }
Charles Yeung
  • 38,347
  • 30
  • 90
  • 130

1 Answers1

1

Just put it in the viewDidLoad / viewWillAppear method. Or, if you have set the delegate of your UITabBar, you can use the delegate method

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item.

Reference - http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITabBarDelegate_Protocol/Reference/Reference.html

max_
  • 24,076
  • 39
  • 122
  • 211