我的应用程序由背景 UIView 中的工具栏和 AVCaptureVideoPreviewLayer 组成。我希望看到工具栏根据设备方向旋转,所以在我的主 ViewController 中,我实现了以下功能:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这工作正常,但是当界面方向改变时,我看到背景 UIView(带有视频层)也在旋转,所以我的视频视图现在向左或向右播放 90 度......这不是很酷!
所以我的问题是:有什么方法可以禁用特定 UIView 上的自动旋转动画?
我见过一个与此类似的问题:Disabling autorotate for a single UIView,但答案不适合我的问题,我真的需要背景视图不要移动,而不是用一种“计数器”来解决问题动画片”。所以我决定提出这个话题。
有任何想法吗 ?
谢谢 !