UIModalPresentationFullScreen旋转问题

时间:2012-05-24 16:27:27

标签: objective-c ios ipad

我正在尝试创建一个全屏显示图像并可以滑动的视图,此视图从另一个类调用,通过UIModalPresentationFullScreen调用,屏幕大小由UIScreen mainScreen.bounds决定。我尝试使用调用者的视图,但在此视图中不需要那里有一个tabbar。从肖像开始时,它的效果很好,但是当从横向调用时,它是空白的。最后,当它旋转成肖像时,我们得到了这个宝石:

portrait image issue

我不知道是什么原因造成的,因为IB中的所有视图都设置为拉伸到屏幕大小并坚持到两侧。

以下是来电者代码:

 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]; 

1 个答案:

答案 0 :(得分:1)

为了使模态视图成为全屏而不会导致此视图,我最终做的是使用不同的演示样式,并确保宽度和高度都设置为灵活。

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

现在视图在全屏幕中正常工作。

相关问题