0

iOS 6でアプリを構築するxcode 4.5でストーリーボードを使用しています。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

このオブジェクトは AVCapture タイプであり、setOrientation があるため、私のコードで prevLayer がビデオ フィードのビューである場合、このようなことができると思いますが、現在の向きに一致するようにある程度変換/回転を行うことができます。

-(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 に答える