简体   繁体   English

我可以从另一个 UIViewController 推送 UINavigationController

[英]Can i Push UINavigationController From another UIViewController

I think its a stupid question but i tried to find a solution for my case but i fail...我认为这是一个愚蠢的问题,但我试图为我的案例找到解决方案,但我失败了......

I have application started with login screen after login i present MainUIViewController, from main i have many buttons one of them to open a new UINavigationController.. is that possible?我在登录后从登录屏幕启动了应用程序,我展示了 MainUIViewController,从 main 开始,我有许多按钮,其中一个按钮可以打开一个新的 UINavigationController .. 这可能吗?

[window addSubview:[navigationController view]];

If i set navigation as main view its work,, but not from another UIViewController..如果我将导航设置为主视图,它的工作,但不是来自另一个 UIViewController ..

also i have tried我也试过

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self.view addSubview:[self.navController view]];// = [self.navController view];
    }
     return self;
}

but fail但失败

thanks for suggestions谢谢你的建议

Is the MainUIViewController the root view controller of the window? MainUIViewController 是窗口的根视图控制器吗? If so, why don't you add it to a UINavigationController and then make the nav controller the root view controller of the window?如果是这样,为什么不将它添加到 UINavigationController 然后使导航控制器成为窗口的根视图控制器? If you're concerned with the MainUIViewController not needing a navigation bar, you can very easily hide this with the setNavigationBarHidden: method on UINavigationController.如果您担心 MainUIViewController 不需要导航栏,您可以使用 UINavigationController 上的 setNavigationBarHidden: 方法轻松隐藏它。 You can then unhide it on the subsequent view controllers.然后您可以在后续的视图控制器上取消隐藏它。 This way, you start off with the navigation controller and simply push new view controllers onto the stack.这样,您从导航控制器开始,然后简单地将新的视图控制器推送到堆栈中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从UIViewController推送UINavigationController - Push UINavigationController from UIViewController 如何在不导入第一个UIViewController类的情况下从UINavigationController中的另一个UIViewController手动取消分配UIViewController? - How can I dealloc manually UIViewController from another UIViewController in UINavigationController without import the first UIViewController class? 从弹出窗口将UIViewController推送到UINavigationController - Push UIViewController to UINavigationController from a popover 我可以从UIViewController中的UINavigationController继承吗? - Can I inherit from a UINavigationController in my UIViewController? 推送没有UINavigationController的UIViewController - push UIViewController without UINavigationController UINavigationController推送到另一个UIViewController - UINavigationController push to a different UIViewController 如何从 FlutterViewController 中“推送”一个 UIViewController - How can I “push” a UIViewController from FlutterViewController 如何从UINavigationController选择到UIViewController - How do I segue from a UINavigationController to a UIViewController 如何用替换的 UINavigationController 推送 UIViewController - How to push UIViewController with replaced UINavigationController 从Storyboard嵌入到容器视图中的UINavigationController不会推送UIViewController - UINavigationController embedded in container view from Storyboard won't push UIViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM