【问题标题】:Locking the Viewcontroller to landscape mode, whatever the orientation of iPhone无论 iPhone 的方向如何,都将 Viewcontroller 锁定为横向模式
【发布时间】:2014-07-30 19:05:28
【问题描述】:

我有一个表tableviewController。单击其中一个单元格时,下一个 viewController 会打开一个 cam 并使用 AVCaptureVideoPreviewLayer 显示视频。为了支持方向,我添加了这些代码行。

  - (NSUInteger)supportedInterfaceOrientations
  {
  return UIInterfaceOrientationMaskAll;
  //return UIInterfaceOrientationMaskLandscapeRight;
  }
  - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  duration:(NSTimeInterval)duration     
  {
  [[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:   
  (AVCaptureVideoOrientation)toInterfaceOrientation];
  }

但我想锁定我的第二个视图控制器,它只以横向模式显示视频。如果 iPhone 处于纵向模式,我仍然希望它只显示横向模式。就像在某些游戏中一样,方向是锁定的。

【问题讨论】:

    标签: iphone ios7 ios5


    【解决方案1】:

    TRy presenting 第二个视图控制器并将方向设置为横向

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    

    详情请参考:https://stackoverflow.com/a/12897383/667586

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-11
      • 2023-03-30
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多