0
我使用的是Apple提供的示例AVCam,但爲了我的應用程序的目的,它有所修改。然而,除了解決其他一些問題之外,沒有任何原始內容真的被觸及。但是,當它在橫向模式下工作時,我遇到了一個主要障礙。AVCam不適用於橫向模式
我有,我從另一個問題了計算器上正確的類下面的代碼:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[CATransaction begin];
if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft){
captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;
} else {
captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;
}
[CATransaction commit];
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
但是,這是行不通的。這段代碼的目的是在移動電話時允許風景。每當你轉移方向的警告在控制檯彈出:
WARNING: -[<AVCaptureVideoPreviewLayer: 0x1ed97620> setOrientation:] is deprecated. Please use AVCaptureConnection's -setVideoOrientation:
不知道該做些什麼來解決這個棄用錯誤,或者棄用是什麼導致它不能轉移到景觀。請幫助!
到錄音過程中禁用自動旋轉: - (BOOL)shouldAutorotate {([[[自拍捕捉管理器]記錄器]是記錄]){ 返回YES; }否則返回NO; } – Laz