You can present the second ViewController modally when you first turn it on, and the first one has a modalPresentationStyle of type UIModalPresentationCurrentContext .
If your first ViewController is built into the ContainerViewController, such as the UINavigationController, you must set modalPresentationStyle on this and you need to present a second ViewController on it.
In your first ViewController, it will look like this:
- (void)buttonTapped:(id)sender { self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext; [self.navigationController presentViewController:[SecondViewController new] animated:YES completion:nil]; }
You also need to configure / implement the desired behavior for the supported interfaces, of course. For example, overriding supportInterfaceOrientations () in the second ViewController, for example:
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
source share