Tag: uialertview autorotate面向

防止AlertView自动旋转

我的应用程序的启动页面设置为肖像只有这一点点的代码: – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait ; } 当应用程序启动时出现用户名和密码input的UIAlertView 。 显示它的方法从viewWillAppear调用。 这对iOS6工作正常,但自iOS7以来,如果我将设备切换到横向,主视图保持纵向,但警报视图和键盘旋转到横向。 另一个奇怪的怪癖是,当我切换回肖像时,只有键盘切换回来(以截短的forms),将警报冻结在横向模式下: 谁能告诉我如何防止这个? -编辑- 自动替代码在另一个类别中被调用: @implementation UINavigationController (Orientation) -(NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } -(BOOL)shouldAutorotate { if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) return NO; else return YES; } @结束 -EDIT 2- 我也尝试在UIAlertView上创build一个类别,但它从来没有被称为: @implementation UIAlertView (Orientation) -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } -(BOOL)shouldAutorotate { return NO; } -EDIT […]