bas*_*han 3 iphone video rotation avfoundation avcam
我正在使用Apple的AVCam示例App.
此示例使用AVFoundation以在视图上显示视频.
我试图从AVCam制作一个没有运气的风景应用程序.
当屏幕方向改变时,视频在视图上旋转显示.有办法解决这个问题吗?
Sam*_*art 10
在创建预览图层时:
captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;
Run Code Online (Sandbox Code Playgroud)
以及管理轮换的方法:
-(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);
}
Run Code Online (Sandbox Code Playgroud)
这对我有用.
| 归档时间: |
|
| 查看次数: |
4248 次 |
| 最近记录: |