How to use multiple iOS custom view controllers without a navigation controller

前端 未结 2 1711
无人及你
无人及你 2020-12-29 13:49

I am building an app that uses multiple types of screens--all which warrant their own custom view controllers. I am successfully switching between view controllers and thei

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 14:12

    Its not a bad solution. You basically set one view as the root view. When you need another UIViewController you set another one. Just be careful for the leaks...

    • Create the rootViewController as property of the class with retain.
    • Before this:

    rootViewController = (UIViewController *)[[BookViewController alloc] init];

    Add this:

    if(rootViewController){
        self.rootViewController=nil;
    }
    

    }

    So you release the previous one.

    Edit 1: One thing: my explanation here is based on the fact that you don't want to use an UINavigationController.

提交回复
热议问题