AppDelegate.h
@interface AppDelegate : NSObject{
UIWindow *window;
UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
AppDelegate.m
@implementation jalanNaviAppDelegate
@synthesize window;
@synthesize tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
self.tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
UITabBarController *tab1Controller = [[[UITabBarController alloc] initWithNibName:@"tab1" bundle:nil] autorelease];
UITabBarController *tab2Controller = [[[UITabBarController alloc] initWithNibName:@"tab2" bundle:nil] autorelease];
UITabBarController *tab3Controller = [[[UITabBarController alloc] initWithNibName:@"tab3" bundle:nil] autorelease];
UITabBarController *tab4Controller = [[[UITabBarController alloc] initWithNibName:@"tab4" bundle:nil] autorelease];
tabBarController.viewControllers = [NSArray arrayWithObjects:tab1Controller, tab2Controller, tab3Controller, tab4Controller, nil];
tab1Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"タブ1" image:[UIImage imageNamed:@"hoge1.png"] tag:0];
tab2Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"タブ2" image:[UIImage imageNamed:@"hoge2.png"] tag:1];
tab3Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"タブ3" image:[UIImage imageNamed:@"hoge3.png"] tag:2];
tab4Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"タブ4" image:[UIImage imageNamed:@"hoge4.png"] tag:3];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}
※UITabBarControllerは、UINavigationControllerの下に作らないこと。
UITabBarControllerとUINavigationControllerを共存させる場合は、
UITabBarControllerの下にUINavigationControllerを作る。
■参考記事
Tab Bar ControllerとNavigation Controllerの組み合わせ
タグ:iPhone
この場合はdelegateでやるんですか?
TabBarControllerを外出しできるんでしょうか?
TabBarControllerは外出しできます。