如何防止iPhone中的自动旋转

时间:2013-02-25 18:26:49

标签: iphone ios rotation autorotate

在我的iphone应用程序中,我希望在设备旋转时只旋转一个视图。我该怎么办呢。 我选择了支持界面方向为纵向,向右旋转并向左旋转

如何只旋转一个视图。 实际上我想在全屏幕时旋转MPMoviePlayer。

3 个答案:

答案 0 :(得分:1)

为您的视图控制器设置返回值NO to shouldAutorotateToInterfaceOrientation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{

return NO;
}

您也可以从Plist中删除它。 UISupportedInterfaceOrientations

答案 1 :(得分:0)

您的视图控制器需要响应

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

返回YES表示允许,NO表示不允许自转。

更好的解释在这里: AutoRotate ONLY MpMoviePlayerControler iOS 6

答案 2 :(得分:0)

在视图控制器中,如果不想旋转,请添加此

 -(BOOL)shouldAutorotate
{
   return NO;
}

在视图控制器中,如果要旋转,请添加此

-(BOOL)shouldAutorotate
{
    return YES;
}