CBredlow
CBredlow

Reputation: 2840

UIModalPresentationFullScreen rotation issues

I'm trying to create a view that displays images full screen and can be swiped, and this view here is being called from another class to present via UIModalPresentationFullScreen, with the screen size being determined by UIScreen mainScreen.bounds. I tried using the caller's view, but there is a tabbar there that will not be needed in this view. When starting from portrait, it works great, but when called from landscape, it's blank. And finally when rotate it to portrait we get this gem:

portrait image issue

I don't know what would be causing it, as all the views in the IB are set to stretch to the size of the screen and stick to the sides.

Here's the caller code:

 MyImageViewController *view = [[MyImageViewController alloc]initWithNibName:@"MyImageViewController"bundle:[NSBundle mainBundle]];
            view.modalPresentationStyle = UIModalPresentationFullScreen;
            view.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
            [self presentModalViewController:view animated:YES];
            view.view.superview.bounds = [[UIScreen mainScreen] bounds]; 

Upvotes: 0

Views: 841

Answers (1)

CBredlow
CBredlow

Reputation: 2840

In order to make the modal view be full screen without causing this view, what I ended up doing was using a different presentation style, and making sure that the width and height were both set to flexible.

[view.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth| 
     UIViewAutoresizingFlexibleHeight];
[view setModalPresentationStyle:UIModalPresentationCurrentContext];

And now the view works fine in full screen.

Upvotes: 1

Related Questions