[英]Tab bar element onclick IOS
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. 代码根本没有到达didSelectViewController。 I am new to IOS.
我是IOS的新手。 Could anyone plz guide where i am going wrong??
任何人都可以指导我哪里出错?
Add delegate method to the UITabBarController 将委托方法添加到UITabBarController
either using storyboard (if you are using) 使用故事板(如果您正在使用)
or as it is UITabBarController do using 或者因为它是UITabBarController使用
self.delegate = self ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.