我的应用程序由一个工具栏和一个放置在后台UIView中的AVCaptureVideoPreviewLayer组成。 我希望看到该工具栏根据设备方向旋转,因此在我的主ViewController中,我实现了以下函数:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这段代码运行良好,但当界面方向改变时,我发现背景UIView(带有视频层)也随之旋转,因此我的视频视图现在向左或向右播放90度...这真的不太好!所以我的问题是:是否有任何方法可以在特定的UIView上禁用自动旋转动画?我看到了一个类似于这个问题的问题:Disabling autorotate for a single UIView,但答案并不能解决我的问题,我真的需要让背景视图不动,而不是通过一种“对抗动画”来绕过问题。因此,我决定提出这个话题。有什么想法吗?谢谢!