アップルのドキュメントを使用して、タブバーとナビゲーションを組み合わせたプログラムを実装しています。
initWithFrame、[黒い画面になる]を呼び出すと機能しません。ただし、以下のコードのままにしておくと、タブバーなしでメイン画面を表示するために機能し、タブバーを使用すると黒い画面になります
ここにコード
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launchOptions { self.tabBarController = [[[UITabBarController alloc] init] autorelease]; StartViewController *startViewControllerView = [[[StartViewController alloc] init] autorelease]; //ojo recomendado por apple!!! VideosViewController* VideosViewController_ = [[[VideosViewController alloc] init] autorelease]; PhotosViewController* PhotosViewController_ = [[[PhotosViewController alloc] init] autorelease]; SocialViewController* SocialViewController_ = [[[SocialViewController alloc] init] autorelease]; self.pagesNavigation = [[[UINavigationController alloc] initWithRootViewController:startViewControllerView] autorelease]; self.pagesNavigation.navigationBarHidden = NO; NSArray* controllers = [NSArray arrayWithObjects:VideosViewController_, PhotosViewController_, SocialViewController_, startViewControllerView, nil]; self.tabBarController.viewControllers = controllers;
[self.window addSubview:startViewControllerView.view];
//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window makeKeyAndVisible];
return YES;
}
したがって、上に示したままにしておくと機能しますが、addSubview をコメントして initWithFrame のコメントを外すと機能しません。
//[self.window addSubview:startViewControllerView.view];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
それで、何が足りないのですか? initWithFrame を呼び出す正しい方法は何でしょうか?
どうもありがとう!