iPhone IOS5 Storyboard, how to load a UIViewController with a custom .xib file?

后端 未结 3 533
礼貌的吻别
礼貌的吻别 2021-02-02 14:15

I have some UIViewControllers from my old iOS4 project, they are using .xib, created in interface builder.

My new project, built for iOS5, uses storyboards.

相关标签:
3条回答
  • You could copy the contents of the xib into the storyboard and then instantiate it using:

    - (id)instantiateViewControllerWithIdentifier:(NSString *)identifier
    

    after setting the identifier on it. If you need the instance of the storyboard you can get it this way:

    [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    
    0 讨论(0)
  • 2021-02-02 14:50

    You cannot mix xibs and storyboards in your project -- it's one of the other, I'm afraid.

    0 讨论(0)
  • 2021-02-02 14:52

    Mike K's answer is false.

    While mixing XIBs and Storyboards doesn't really solve Alex's problem, it is quite possible to do within the same project.

    See: https://stackoverflow.com/a/8516479/1309238 re: loading a second storyboard.

    I'm not sure if including a "Main Storyboard" in your Target Summary is advisable if you plan to do this, but if you've loaded a XIB instead of a storyboard to begin with, you can modify the code linked above to load the storyboard after the XIB.

    I'm not sure if you can jump into the middle of a storyboard from a XIB, which may have been what Mike meant.

    0 讨论(0)
提交回复
热议问题