How to change view on button click in iPhone without navigation controller?

后端 未结 5 1755
小蘑菇
小蘑菇 2021-01-03 11:54

I want to know how to change view on button click in iPhone without navigation controller?

5条回答
  •  一向
    一向 (楼主)
    2021-01-03 12:06

    If you're doing this with a UIViewController, you would probably do this like following:

    - (IBAction)change {
        UIViewController* viewController = [[UIViewController alloc] init];
        [self.view addSubView];
        // Save the UIViewController somewhere if necessary, otherwise release it
    }
    

    Not sure why you don't want to use a UINavigationController though. If it's the navigation bar at the top you don't want to see, there's a property for that so you can hide that bar. Not sure about it's name, probably navigationBarHidden or something like that. You can look that up in the API.

提交回复
热议问题