简体   繁体   中英

Custom Navigation controller in Storyboard

Inside this i am creating the custom navigation controller and i have view as storyboard but that view is not loading

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

//create the navigation controller and add the controllers view to the window
_navigationController = [[UINavigationController alloc] init];
[self.window addSubview:[self.navigationController view]];

//check if the first viewcontroller eixsts, otherwise create it
if(self.firstViewController == nil)
{
    ViewController *firstView = (ViewController *)[mainStoryBoard instantiateViewControllerWithIdentifier:@"mainView123"];
   // ViewController *firstView = [[ViewController alloc] init];
    self.firstViewController = firstView;
}

//push the first viewcontroller into the navigation view controller stack
[self.navigationController pushViewController:self.firstViewController animated:YES];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

firs you should set your navigation as rootviewcontroller then try something like this.

 UIStoryboard *storyboard =[UIStoryboardstoryboardWithName:@"MainStoryboard_iPhone" bundle:nil];
    MyNewViewController *myVC = (MyNewViewController *)[storyboard    instantiateViewControllerWithIdentifier:@"myViewCont"];
     self.firstViewController = myVc;

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