从viewWillAppear调用UIAlertView时,iOS 8会冻结

时间:2014-10-18 18:34:42

标签: ios ios8 uialertview

我有一个iOS应用程序,如果用户打开了教程模式,我会在用户打开页面时弹出警告。

iOS 7完全正常,但在iOS 8上显示警报后挂机。没有关闭应用程序或任何东西,只是字面上冻结界面。它实际上并非100%实际发生,但可能约为90%。

有什么想法?我是否以某种方式接近这个错误?

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    if ([DataController sharedInstance].tutorialInProgress) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test" message:@"Test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];

    }

}

编辑:我进一步研究了这一点,并意识到只有当我从上一个视图控制器通过警报视图弹出时才会发生这样的事情:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 1) {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

进一步编辑(对不起):由于这似乎是一个时间问题,我尝试并能够使用以下方法解决此问题:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 1) {
        [self.navigationController performSelector:@selector(popViewControllerAnimated:) withObject:[NSNumber numberWithBool:YES] afterDelay:0.1];
    }
}

但它看起来很黑,所以如果有更好的解决方案,请告诉我。

0 个答案:

没有答案