这里我尝试将navigationcontroller设置为rootviewcontroller,但它显示错误。如何解决它。
额外的论点'捆绑'在电话中。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
let nav = UINavigationController()
let vc = MyNavigationController(nibName: "MyNavigationController", bundle: nil)
nav.pushViewController(vc, animated: false)
self.window!.rootViewController = nav
self.window!.makeKeyAndVisible()
nav.setNavigationBarHidden(true, animated: false)
return true
}
答案 0 :(得分:3)
var nav1 = UINavigationController()
var mainView = ViewController(nibName: nil, bundle: nil) //ViewController = Name of your controller
nav1.viewControllers = [mainView]
self.window!.rootViewController = nav1
self.window?.makeKeyAndVisible()
OR
var navigationController = UINavigationController(rootViewController: viewController));
答案 1 :(得分:2)
把它在Objective-C
中 self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
viewcontroller=[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
UINavigationController *navigation=[[UINavigationController alloc] initWithRootViewController:viewcontroller];
self.window.rootViewController=navigation;
[window makeKeyAndVisible];