0

我有一个适用于所有方向的应用程序。

对于 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 然后设备旋转,则背景黑色阴影出现在错误的方向。

截屏

这只发生在 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 中。

4

1 回答 1

0

要结束这个问题...

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

我通过实现我的自定义警报(的子类UIViewController)解决了这个问题。

于 2013-11-22T10:37:58.217 回答