简体   繁体   中英

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?

[window addSubview:[navigationController view]];

If i set navigation as main view its work,, but not from another 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? If so, why don't you add it to a UINavigationController and then make the nav controller the root view controller of the window? If you're concerned with the MainUIViewController not needing a navigation bar, you can very easily hide this with the setNavigationBarHidden: method on UINavigationController. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM