2013-10-20 112 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 
相關問題