Tag: autorotate

手动旋转方法断开侧开关

目前,我正在为iPad的绘图应用程序工作。 我需要重新定位和旋转应用程序中的工具栏时,将其放在不同的方向,同时保持绘图区在同一个地方。 我在这里find了一个方法来做到这一点。 它使用NSNotificationCenter监视轮换更改。 这将调用一个自定义的didRotate:方法,它将根据UIDeviceOrientation旋转和重新定位我的工具栏。 这部分工作正常。 但是,只要iPad上的侧面开关locking方向,工具栏重新定位到该位置即将启动。 例如:如果我在横向左侧启动应用程序并将其旋转到纵向,则工具栏将重新定位到屏幕的底部。 但是,一旦我使用滑动开关,它就会移动到屏幕左侧的横向左侧。 我正在使用的方法都在下面。 – (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; } – (void)didRotate:(NSNotification *)notification { UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation interfaceOrientation; bool orientationFound = YES; if (deviceOrientation == UIDeviceOrientationPortrait) { interfaceOrientation = UIInterfaceOrientationPortrait; } else if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown) { interfaceOrientation = […]

设备向上/向下倾斜和横向触发方向通知

我有一个iOS7的应用程序构build与UIViewController,应该支持风景左右和纵向肖像颠倒和其他ViewControllers应支持横向左右方向。 我已经使用通知来通知方向更改并相应刷新子视图。 我也检查UIDevice的当前方向旋转。 我面对的问题是,即使轻微的摇晃或倾斜,也会触发更新观点的方向改变方法 。 我甚至在那里和那里得到奇怪的视图框架。 我对viewDidLoad和viewWillDisappear分别使用了beginGeneratingDeviceOrientationNotifications和endGeneratingDeviceOrientationNotifications 。 有什么办法可以限制到单独的设备旋转? [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDidRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; // adding observer to notify when device rotates. deviceDidRotate:即使是我实际上想要避免的一个小的倾斜或摇晃。 UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; //Ignoring specific orientations if (orientation == UIDeviceOrientationFaceUp||orientation == UIDeviceOrientationFaceDown ||orientation == UIDeviceOrientationUnknown) { return; } if ((UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation))) { [UIViewController attemptRotationToDeviceOrientation]; } 为了避免倾斜效应,我使用这种委托方法 – (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation […]

如何处理AVCaptureVideoPreviewLayer中的自动转换?

我的应用程序支持除了PortraitUpsideDown以外的所有方向。 在我的视图层次结构中,我有一个AVCaptureVideoPreviewLayer作为UIImageView的顶层视图的子层。 然后在视图下方的层次结构中显示控件的几个叠加视图。 覆盖视图正常工作方向的变化,但我不怎么这个AVCaptureVideoPreviewLayer。 我希望它的行为像在相机应用程序,以便previewLayer保持不变,控制顺利重组。 现在,由于主视图在方向改变时被旋转了,所以我的预览图层也被旋转了,这意味着在横向视图中它保持纵向视图,只取得屏幕的一部分,相机的图片也旋转了90度。 我设法手动旋转预览图层,但是它有这个方向改变animation,这导致在animation期间看到背景。 那么在使previewLayer保持不变的情况下自适应控件的正确方法是什么?

在iOS8的单个子视图上禁用自动旋转

我正在写一个绘图应用程序,我不想绘图视图旋转。 同时,我希望其他控件根据设备的方向很好地旋转。 在iOS 7中,我已经解决了这个问题: – (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { float rotation; if (toInterfaceOrientation==UIInterfaceOrientationPortrait) { rotation = 0; } else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) { rotation = M_PI/2; } else if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight) { rotation = -M_PI/2; } self.drawingView.transform = CGAffineTransformMakeRotation(rotation); self.drawingView.frame = self.view.frame; } 但在iOS 8上,即使函数被调用并且转换设置正确,也不会阻止视图旋转。 我已经尝试创build一个视图控制器,它只是防止它的视图的旋转,并将其视图添加到视图层次结构,但它不响应用户input。 有任何想法吗? 谢谢!