[英]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.