IOS 7: A transparent Viewcontroller control over another Viewcontroller with different orientation behavior

I have 2 ViewControllers (IOS7) and I want to show the second one in the first with a transparent background and different orientations.

For example: clicking a button on the first ViewController will call the second ViewController, but the first will still be displayed in the transparent areas of the second ViewController. If I rotate the phone, only the second ViewController will rotate until the first (the one in the background) remains in the same orientation.

Any suggestions? Thank you

0
source share
1 answer

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; } 
0
source

Source: https://habr.com/ru/post/1202369/


All Articles