2016-03-31 14 views
2

私はAVCapturesessionを使用して画像をキャプチャするアプリケーションを持っていますが、UIViewが内部にある単一のView Controllerがあり、このビュー内でセッションを実行します。ランドスケープモードの回転問題を修正しました

私のアプリケーションがポートレートモードで読み込まれると、全画面が開き、横長モードにも回転しても全画面表示されます。私のビューは画像をキャプチャするために使用されているため、UIViewすべてがうまくいきます。

唯一の問題は、私のアプリが横長モードで開かれたときにフルスクリーンで表示されないようにすることです。

これを解決するにはどうすればいいですか、iOSアプリを強制的にポートレートモードで開いてから回転させる方法がありますか?

答えて

1

私は同じ問題に直面しました。このメソッドをアプリケーションデリゲートクラスに実装する必要があります。ここにexample.Hopeこれはあなたが必要とするものです。お使いのカメラの層のこのメソッドフレームで

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window 
{ 
    if([window.rootViewController isKindOfClass:[HRMHomeViewController class]]) 
    { 
     id homeViewController = (HRMHomeViewController*)window.rootViewController; 
     if ([[homeViewController presentedViewController] 
      isKindOfClass:[HRMCapturedScreenViewController class]]) 
      return UIInterfaceOrientationMaskPortrait; 
    } 
    return UIInterfaceOrientationMaskAll; 
} 

向き

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
             duration:(NSTimeInterval)duration 
{ 
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation 
              duration:duration]; 
    self.captureManager.cameraLayer.frame = self.videoView.bounds; 
} 

に応じhelp.Hereが双方向であるかUINavigationControllerのカテゴリを作るか、それを継承することができますUINavigationControllerのメソッドがあります回転します。

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController 
- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController 
関連する問題