我想知道,我們如何在UINavigationController中設置UIViewController而不使用UITableView到其根視圖控制器。有關於此的任何幫助?提前致謝。如何將UIVIewController設置爲RootViewController?
1
A
回答
-3
的UINavigationController pushViewController:動畫:
8
你能做到這一點,如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
UIViewController *myViewController = [[UIViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
self.window.rootViewController = navigationController;
// ...
}
可以更換類的myViewController
和/或使用筆尖如果你想進行初始化。
1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:[[OptionViewController alloc]initWithNibName:@"OptionViewController" bundle:nil]];
self.window.rootViewController=nav;
self.window.backgroundColor = [UIColor grayColor];
[self.window makeKeyAndVisible];
return YES;
}
0
它的工作對我來說:
設置你的窗口tabviewcontroller,那麼它會正常工作。
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UITabBarController *tabVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MyMainView"];
[window setRootViewController:tabVC];
相關問題
- 1. 當父UIViewController設置爲RootViewController時,UIView不會成爲First Responder
- 2. 如何在swift中從我的UIViewController設置rootViewController?
- 3. 如何獲取/設置rootViewController?
- 4. Monotouch:UINavigationController,設置RootViewController
- 5. 如何將RootViewController設置爲SplitViewController中的分組表格
- 6. 如何動畫設置rootViewController窗口
- 7. IOS uiviewcontroller:如果rootviewcontroller設置爲一個新的viewcontroller將視圖控制器是免費的
- 8. 爲ipad 3.2設置rootViewController不起作用
- 9. 將RootViewController分配給UIViewController會發出警告 - 爲什麼?
- 10. Swift:設置rootViewController不工作?
- 11. 如何在UIViewController中設置視圖
- 12. 如何在UIViewController中設置parentViewController?
- 13. iPhone:如何設置UIViewController框架?
- 14. 股票UIViewController不能設置爲IBOutlet?
- 15. Swift在AppDelegate中設置rootViewController延遲
- 16. 設置UIWindow的rootViewController是做什麼的?
- 17. 如何設置rootViewController指向指針的地址
- 18. Xcode如何通過故事板隱式設置rootViewController?
- 19. 將UITabBarDelegate設置爲UIViewController時,應用程序崩潰
- 20. 在其他UIViewController中將UIViewControllers設置爲屬性
- 21. UIViewController&UITableViewController - 設置頁面
- 22. 如何從NavigationController將值推送到rootViewController?
- 23. 如何將rootViewController更改爲尚未加載的VC?
- 24. 如何將RootViewController更改爲另一個XIB?
- 25. 如何在普通的UIViewController之後設置一個自定義的UIViewController?
- 26. 如何將logrus時間設置爲UTC
- 27. StAX - 如何將XMLInputFactory.IS_VALIDATING設置爲true?
- 28. 如何將位列設置爲空?
- 29. 如何將超時設置爲JSONP?
- 30. 如何將dojox.mobile.View設置爲高度100%