代码之家  ›  专栏  ›  技术社区  ›  Giuseppe Garassino

iOS 6:UIAlertView轮换问题

  •  0
  • Giuseppe Garassino  · 技术社区  · 11 年前

    我有一个可以全方位工作的应用程序。

    对于iOS 6,我使用

    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
    }
    

    对于iOS 5

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return YES;
    }
    

    这部分似乎有效。

    然后,因为我想停止旋转动画,所以我实现了以下方法:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    
        [UIView setAnimationsEnabled:NO];
    }
    
    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    {
        [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    
        [UIView setAnimationsEnabled:YES];
    }
    

    一切正常,但如果我显示UIAlert,然后设备旋转,背景黑色阴影就会出现在错误的方向。

    Screenshot

    这种情况只在iOS 6中发生,而在iOS 5、实际设备和模拟器中不会发生,并且只有当我阻止旋转设置动画时才会发生。

    知道吗?

    编辑:这是我的rootViewController

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Other things
    
        self.rootViewController = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]] autorelease];
        self.window.rootViewController = self.rootViewController;
        [self.window makeKeyAndVisible];
    
        return YES;
    }
    

    窗口存储在NIB中。

    1 回复  |  直到 11 年前
        1
  •  0
  •   Giuseppe Garassino    11 年前

    要结束此问题。。。

    我不知道是什么问题导致了这个问题,我想是与iOS版本有关。

    我通过实现我的自定义警报(的一个子类 UIViewController ).