これは非常に繰り返されるトピックですが、私はそれを動作させることはできません。TabBarController didSelectViewControllerが動作しない
MainTab.h:
#import <UIKit/UIKit.h>
@interface MainTab : UITabBarController<UITabBarControllerDelegate, UITabBarDelegate> {
IBOutlet UITabBarController *tabController;
}
@property (nonatomic,retain) IBOutlet UITabBarController *tabController;
@end
MainTab.m
- (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にリンクしてみてください:
しかし、それは仕事をdoesntの、接続は何ですか?あなたの@interface
(とあなたのその後の画面のスナップショット)に基づいて
どのように作成していない 'MainTab'オブジェクト?? –
@Robはい、あなたは正しいです - 私は何とか質問の「コントローラ」部分を見逃していました。それはタブバーコンポーネントを備えたカスタムコントローラだと思っていました。私は自分のコメントを削除し、あなたの詳細な答えに投票しました。 – dasblinkenlight