AVCaptureVideoOrientation永远不会改变

时间:2013-10-20 19:54:37

标签: ios objective-c orientation avcapturesession

我需要获得设备方向,但是,可能因为我正在开发的应用程序仅支持纵向方向,它似乎永远不会改变。我尝试过[AVCaptureConnection videoOrientation][[UIDevice currentDevice] orientation][[UIApplication sharedApplication] statusBarOrientation],但无济于事。方向总是说“肖像”。

有没有办法获得真正的方向?

1 个答案:

答案 0 :(得分:0)

我不确定我的问题是否正确,但请尝试一下。它可能对你有帮助。

在.h文件中: -

@property (strong, nonatomic) AVCaptureVideoPreviewLayer* previewLayer;

在.m文件中: -

// CHECK FOR YOUR APP
self.previewLayer.frame = CGRectMake(0, 0, 200, 200);
//self.previewLayer.orientation = AVCaptureVideoOrientationPortrait;
self.previewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait;

// CHECK FOR YOUR APP
//[self.view.layer insertSublayer:self.previewLayer atIndex:0];   // Comment-out to hide preview layer
相关问题