Ios AVCaptureVideoPreviewLayer,能够使用Quicktime以横向模式录制

Ios AVCaptureVideoPreviewLayer,能够使用Quicktime以横向模式录制,ios,objective-c,swift,avfoundation,Ios,Objective C,Swift,Avfoundation,所以我现在有一个摄像头应用程序。我有它,所以它只能在纵向模式下工作,但你仍然可以在横向模式下录制视频和拍照。我使用以下代码来处理该问题: videoConnection?.videoOrientation = self.orientation() 但是,由于应用程序本身未注册横向模式,因此无法通过横向中的quicktime录制屏幕(它保持纵向)(quicktime>文件>录制电影>选择设备名称) 有办法解决这个问题吗?我不需要实际更改设备的任何内容来支持环境,我只希望能够在quicktime中

所以我现在有一个摄像头应用程序。我有它,所以它只能在纵向模式下工作,但你仍然可以在横向模式下录制视频和拍照。我使用以下代码来处理该问题:

videoConnection?.videoOrientation = self.orientation()
但是,由于应用程序本身未注册横向模式,因此无法通过横向中的quicktime录制屏幕(它保持纵向)(quicktime>文件>录制电影>选择设备名称)


有办法解决这个问题吗?我不需要实际更改设备的任何内容来支持环境,我只希望能够在quicktime中以这种方式记录,但UI中的任何内容都不需要更改。

您可以为
UIDevice
设置调用
BegingeratingDeviceOrientationNotification
,并订阅
UIDeviceOrientationIDChangeNotification
。之后,您可以在代码中使用
UIDevice
的方向属性


有关详细信息,请参考类。

尝试为
UIDevice
设置呼叫
BegingeratingDeviceOrientationNotifications
,并将其订阅到
UIDeviceOrientationIDChangeNotification


使用或保持
ui设备的比例

您需要做的是检测方向的变化:

查看此苹果文档,了解更多详细信息

下面是中的一个示例实现 &&

这就是我最后要做的!利用有标记的答案

func orientationChanged() {
    var orient = UIDevice.currentDevice().orientation

    if orient == UIDeviceOrientation.Portrait {
        print("PORT")
                UIApplication.sharedApplication().statusBarOrientation = UIInterfaceOrientation.Portrait
    } else if orient == UIDeviceOrientation.LandscapeLeft {
        print("OR ARE YOU CRASHING")
                UIApplication.sharedApplication().statusBarOrientation = UIInterfaceOrientation.LandscapeRight
    } else if orient == UIDeviceOrientation.LandscapeRight {
        print("WHY YOU CRASHING")
                UIApplication.sharedApplication().statusBarOrientation = UIInterfaceOrientation.LandscapeLeft
    } else if orient == UIDeviceOrientation.PortraitUpsideDown {
                UIApplication.sharedApplication().statusBarOrientation = UIInterfaceOrientation.PortraitUpsideDown
    }

你好非常感谢。我不太确定我将如何使用这个。有什么例子吗?@user2433617这里是对您的请求的一个回答,例如-