问题描述
我的应用程序由后台UIView中的工具栏和AVCaptureVideoPreviewLayer组成。
我想看到工具栏按设备方向旋转,所以在我的主ViewController中,我实现了这个功能:
My application is composed of a toolbar and an AVCaptureVideoPreviewLayer in a background UIView.I'd like to see that toolbar rotate regarding the device orientation, so in my main ViewController, I implemented the function :
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这样可以正常工作,但是当界面方向改变时,我看到了背景UIView(带有视频图层)也在旋转,所以我的视频视图现在向左或向右播放90度......这真的很酷!
所以我的问题是:有什么方法可以禁用特定UIView上的自动旋转动画?
This works fine, but when the interface orientation is changed, I see that the background UIView (with a video layer) is also rotating, so my video view is now playing 90 degrees left or right... Which is not really cool !
So my question is : is there any way to disable the auto-rotation animation on a specific UIView ?
我看到过一个类似的问题:,但答案不适合我的问题,我真的需要背景视图不要移动,不要用一种计数器动画解决问题。所以我决定提出这个话题。
I have seen one similar question to this one : Disabling autorotate for a single UIView, but the answers doesn't fit my problem, I really need the background view to do not move, not to get around the problem with a kind of "counter animation". So I decided to bring up this topic.
任何想法?
谢谢!
推荐答案
试试这个:
myVideoCaptureLayer.orientationSupported = NO;
这篇关于禁用UIView的自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!