Reputation: 953
I have a master utility application embedded in a tab bar. Now, for this tab bar, i have the following.
@interface MainTabViewController : UITabBarController< UITabBarControllerDelegate>{
}
@end
@implementation MainTabViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
NSLog(@"One");
if(self.tabBarController.selectedIndex==1)
{
NSLog(@"clicked");
}
if (self.tabBarController.selectedIndex==2) {
NSLog(@"Helo");
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tabBarController.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
The code is not reaching the didSelectViewController at all. I am new to IOS. Could anyone plz guide where i am going wrong??
Upvotes: 0
Views: 204
Reputation: 444
Add delegate method to the UITabBarController
either using storyboard (if you are using)
or as it is UITabBarController do using
self.delegate = self ;
Upvotes: 2