1

我的应用主要支持iOS6+。在考虑iOS5时,我添加了以下判断。

 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0) { 
    self.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:readerViewController animated:YES completion:NULL];
 }
 else {
    self.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentModalViewController:readerViewController animated:YES];
}

但是,模态视图在我的横向应用程序中垂直显示。我的意思是,我的应用程序是横向的,模态视图只是“躺在”那里,而不是我设置的全屏,只是覆盖部分屏幕,而未覆盖的是黑色。

我想知道是否有人可以提供帮助。谢谢转发。

4

2 回答 2

1

丁香:- tia 说的是正确的。你不需要担心版本。我认为你没有为 ModalView 设置所需的视图 Oreintation 的方向。

意味着,如果您的 mainViewController(您从中呈现 ModalView)仅支持横向模式,那么在 modalViewController 中,您必须设置方向,限制为仅在横向视图中呈现。

您应该在 modalViewController 中编写在 mainViewController 中编写的方向代码。

这些方法:-

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    //    return YES;

}

-(BOOL)shouldAutorotate{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

如果它不能解决您的问题并且确实有帮助,请回复,您知道该怎么做;)。

于 2013-06-04T08:57:43.843 回答
0

首先,从 iOS 5.0presentViewController:animated:completion:开始就已经可用,因此您不必担心版本问题。如果您真的想检查该方法的可用性,您应该使用

if ([self respondToSelector:@selector(presentViewController:animated:completion:)])

对于模态视图,您需要设置modalTransitionStylemodalPresentationStyle呈现的控制器上,例如readerViewController在您的情况下。所以你的代码应该是

readerViewController.modalTransitionStyle = UIModalPresentationFullScreen;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:readerViewController animated:YES completion:NULL];
于 2013-06-04T05:50:46.393 回答