更改ViewController而不设置navigationitem

时间:2014-10-26 16:48:42

标签: ios swift

我正在通过swift中的instantiateViewControllerWithIdentifier在两个navigationviewcontroller之间移动,但是两个navigationcontroller的后一个设置了一个后导航项目,我不想这样做,因为它从登录到家!

有谁知道如何禁用此操作?

var vc = storyboard.instantiateViewControllerWithIdentifier("mainUserView") as UIViewController

self.showViewController(vc, sender: vc)

2 个答案:

答案 0 :(得分:0)

如何在家庭视图控制器上以模态方式显示具有登录viewcontroller的导航控制器? 如果您不需要像登录那样从登录中显示另一个视图控制器,您可以在不将其嵌入导航控制器的情况下以模态方式呈现它。

例如,我在AppDelegate didFinishLaunchingWithOptions方法

中执行此操作
UINavigationController *homeNavigationController = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"homeNavigationController"]; // the navigation Controller that has HomeViewController as its root

[self.window setRootViewController: homeNavigationController];

[self.window makeKeyAndVisible];

if (![User isUserRegistered]) { //if user is not registered show login screens
    UIViewController *introNavigationController = [mainStoryboard instantiateViewControllerWithIdentifier: @"IntroNavigationController"];  // the navigation Controller that has LoginViewController as its root
    [self.window.rootViewController presentViewController:introNavigationController animated:NO completion:nil];
}

答案 1 :(得分:0)

当你需要回到家并消失回按钮时,你可以在登录课上写一些单词

   `//let backButton disappear
    navigationItem.leftBarButtonItem = UIBarButtonItem()
    navigationItem.leftBarButtonItem?.title = ""`