Loading UINavigationController from another nib automatically by UITabBarController

后端 未结 5 777
無奈伤痛
無奈伤痛 2021-02-06 16:57

I think I\'ve found the cause: Document Info window in IB has a warning: \"\'Selected Navigation Controller (Second)\' has nib name property set to \'SecondView.nib\', but t

5条回答
  •  面向向阳花
    2021-02-06 17:10

    I haven't tried setting up UINavigationController via IB. I have multiple screens, each is stored in separate xib and there's a corresponding class that extends UIViewController. In applicationDidFinishLaunching I initialize UIViewControllers using xib's but then manually create UINavigationController, add navigation controller's view to window and push first view to navigation controller.

    Not sure if that helps.

    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
        navigationController = [[UINavigationController alloc] init];
    
        FirstViewController * viewController = [[FirstViewController alloc] 
                                               initWithNibName:@"FirstView"
                                                        bundle:nil];
        [navigationController pushViewController:viewController animated:NO];
        [viewController release];
        [window addSubview:navigationController.view];
        [window makeKeyAndVisible];
    }
    

    Above FirstViewController extends UIViewController, in IB you create your view then set File's owner class to your class (e.g. here FirstViewController) and connect the File's owner view to the UIView's view.

提交回复
热议问题