0
林實現組合選項卡欄和導航編程,使用apple documentation,iphone組合的選項卡欄和navigationController
調用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的正確方法?
非常感謝!
將autoreleased viewController作爲文檔示例進行管理;我需要解決的是[tabBarController setViewControllers:tabs animated:NO];這不是在文檔!,謝謝! – MaKo