Objective c 如何使所有视图仅为纵向模式

Objective c 如何使所有视图仅为纵向模式,objective-c,xcode,storyboard,mpmovieplayercontroller,ios6,Objective C,Xcode,Storyboard,Mpmovieplayercontroller,Ios6,我正在使用xcode 4.5的故事板,在iOS 6上构建一个应用程序。我在mpvideoviewcontroller中有一个视频。当我观看视频时,它是横向的,但是对于所有其他视图(我有喜欢的歌曲和新闻),我如何使所有其他选项卡都是纵向的?我只想把视频放在风景中。是不是有什么我错过了,我真的错过了。每个选项卡上的方向都是纵向的,在xcode项目摘要屏幕上,我启用了左侧和右侧。我为那些我只想成为肖像的人添加了这行代码 - (BOOL)shouldAutorotateToInterfaceOrient

我正在使用xcode 4.5的故事板,在iOS 6上构建一个应用程序。我在mpvideoviewcontroller中有一个视频。当我观看视频时,它是横向的,但是对于所有其他视图(我有喜欢的歌曲和新闻),我如何使所有其他选项卡都是纵向的?我只想把视频放在风景中。是不是有什么我错过了,我真的错过了。每个选项卡上的方向都是纵向的,在xcode项目摘要屏幕上,我启用了左侧和右侧。我为那些我只想成为肖像的人添加了这行代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
     return NO;
 }
有什么建议吗


仅供参考:如果我在Xcode for orientations的摘要页面中更改为仅纵向模式,则每个视图都处于纵向模式,并且我希望我的视频视图处于横向模式而不是纵向模式。

将该方法更改为仅在纵向模式下返回true:

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

iOS 6在AppDelegate上支持此选项

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
       // check if you are in video page --> return landscape
       return (isVideoPage)?UIInterfaceOrientationMaskAllButUpsideDown:UIInterfaceOrientationMaskPortrait;
    }

希望有帮助。

我想你可以这样做,在我的代码中,prevLayer是带有视频提要的视图,因为这个对象是AVCapture类型,它有setOrientation,但是你可以进行某种程度的变换/旋转以匹配当前方向,希望有帮助

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    switch ([[UIDevice currentDevice]orientation]) {
        case UIDeviceOrientationLandscapeLeft:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeRight];
            break;
        case UIDeviceOrientationLandscapeRight:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft];
            break;
        default:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft];
            break;
    }

}

我会在这个主题上为您做更多的研究,但我知道,作为一个快速的响应,iOS 6 SDK的shouldAutorotateToInterfaceOrientation已被弃用,现在您应该使用-(BOOL)shouldAutorotate方法,如果您的问题与iOS 6的轮换问题有关,而不是参考[此][1]链接。[1] :这个不行。我在iOS 6上。上述方法已折旧。