【问题标题】:iPad ViewController segues not working within UIActionSheetiPad ViewController segues 在 UIActionSheet 中不起作用
【发布时间】:2015-07-26 17:07:37
【问题描述】:

我有一个最初为 iPhone 开发的应用程序,以 MapViewController 作为主屏幕,以及从 UI ActionSheet 中调用的帮助屏幕和教程屏幕。适用于 iPhone。

在 iPad 上运行时,我无法进入帮助屏幕并出现以下运行时错误:

Warning: Attempt to present <HelpViewController: 0x177076c0>  on <MapViewController: 0x177d7060> which is already presenting <UIAlertController: 0x17732620>

如果我添加以下代码行

[self dismissViewControllerAnimated:YES completion:nil];

然后我确实进入了帮助屏幕,但出现以下错误:

Warning: Attempt to dismiss from view controller <MapViewController: 0x17d75660> while a presentation or dismiss is in progress!

当我退出帮助屏幕时,MapView 不会出现,但是选择一个新的 baseMap 会使它恢复活力。

因此,代码在 iPhone 上运行良好。在 iPad 上,我收到一条错误提示

1) 不要在 UIAlertController 处于活动状态时打开新视图,或者 2) 不要关闭视图,因为关闭已经在进行中...

对我来说,这似乎是一个时间问题,我已经尝试了“睡眠”语句和一些代码来提供短暂的延迟,但都没有帮助。

有人有什么想法吗?

【问题讨论】:

    标签: ios objective-c iphone ipad uiviewcontroller


    【解决方案1】:

    您必须为 iPad 设置操作表,如下所示..

            UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Some Title" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil,nil];
            if(!IS_IPad){
                [popup showInView:[UIApplication sharedApplication].keyWindow];
            }else{
                [popup showFromRect:CGRectMake((CGRectGetWidth(self.view.frame)-200)/2, self.imgLogo.frame.origin.y,200, 200) inView:self.view animated:YES];
            }
    

    你的行动表在这两种情况下都有效。

    【讨论】:

    • 动作表工作正常,并且允许在 iPhone 和 iPad 上同样好地选择动作,它在出现问题的过程中。我的错,我忘了提到转换是通过 performSegueWithIdentifier 完成的,如 '[self performSegueWithIdentifier:@"ShowHelpSegue" sender:self];'
    【解决方案2】:

    当您尝试呈现/关闭带有动画的视图而另一个动画仍在进行中时,会出现此警告。这可能是因为在从 UIActionsheet 进行选择时,它会产生动画并逐渐消失,同时另一个视图控制器会出现动画。如果您在延迟 0.2 秒后关闭视图控制器可能会有所帮助

    【讨论】:

      猜你喜欢
      • 2018-02-08
      • 2011-05-03
      • 2012-09-08
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多