我想與另一個UINavigationViewController和UIViewController子類創建UITabBarViewController的主屏幕。當與UITabBarController結合UINavigationBar顯示不正確
在實際應用中,主要有:
- 兩個製表裝載NewsController和視頻控制器
- HomeViewController加載應用程序完成啓動後立即時。
這是我的應用程序拍攝畫面。
HomeViewController
導航欄有半
NewsViewController
這是我的代碼。
//在TabBarWithHomeDelegate.m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
homeViewController = [[HomeViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]init];
nav.navigationItem.title = @"Tab 1 Data";
[nav pushViewController:homeViewController animated:NO];
[self.tabBarController setSelectedViewController:nav];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
//在NewsViewController.m對home鍵
-(IBAction) homeButtonClick:(id)sender
{
TabBarWithHomeAppDelegate * appDelegate
= [[UIApplication sharedApplication] delegate];
UITabBarController * tabBarController = appDelegate.tabBarController;
[tabBarController setSelectedViewController:nil];
[tabBarController setSelectedViewController:appDelegate.homeViewController];
}
觸摸此外,我附上源代碼。如果你看到並且幫助我解決這個問題,我將會畢業。事實上,我嘗試自己做了近6個小時。
嗨塞巴斯蒂安塞利斯, 非常感謝。不幸的是,將presentModalViewController設置爲您的建議,HomeViewController不會顯示在屏幕頂部。 :) – embarus
它應該。確保您正確調用它並閱讀presentModalViewController文檔。 –
它現在可以工作,非常感謝,但是我怎樣才能控制在nib中定義的HomeViewController中的視圖大小。當它加載到tabBarController的模式時,它總是填充到全屏幕大小。我想要在屏幕底部顯示tabbar。 – embarus