0

我正在使用带有 xcode 4.5 的情节提要,在 iOS 6 上构建应用程序。我在 mpvideoviewcontroller 中有一个视频。当我观看视频时它会变成横向,但是对于所有其他视图(我喜欢歌曲和新闻),我如何使它成为所有其他选项卡的纵向?我只希望视频是横向的。有什么我想念的吗,我有。每个选项卡上的方向为纵向,在 xcode 项目摘要屏幕上我启用左右。我为那些我只想纵向显示的代码添加了这行代码。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
     return NO;
 }

有什么建议么?

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

4

3 回答 3

1

iOS 6 在 AppDelegate 上支持这个

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

希望有所帮助。

于 2012-12-27T15:43:25.387 回答
0

我想你可以做这样的事情,在我的代码中 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;
    }

}
于 2012-12-28T00:54:25.287 回答
0

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

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
于 2012-09-22T03:52:58.543 回答