我知道这是一个非常重复的话题,但我无法让它发挥作用。
MainTab.h:
#import <UIKit/UIKit.h>
@interface MainTab : UITabBarController<UITabBarControllerDelegate, UITabBarDelegate> {
IBOutlet UITabBarController *tabController;
}
@property (nonatomic,retain) IBOutlet UITabBarController *tabController;
@end
主选项卡
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
NSLog(@"main tab");
[super viewDidLoad];
self.tabBarController.delegate = (id)self;
[self setDelegate:self];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSLog(@"selected %d",tabBarController.selectedIndex);
}
我找不到我缺少的东西,任何帮助将不胜感激。
现在我尝试将它链接到 MainStoryBoard:
但它不起作用,有什么联系?