2013-10-20 114 views
0

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

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

回答

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 
相关问题