呈现 UIActivityViewController 时的警告 [英] Warning when presenting UIActivityViewController

查看:29
本文介绍了呈现 UIActivityViewController 时的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用下面的代码显示 UIActivityController 时,它会显示,但控制台显示Warning: Attempt to present <UIActivityViewController: 0x7f8788e7aed0> on <MyApp.CustomTableViewController: 0x7f8788e3db60> 已经呈现(空)".

When i present an UIActivityController using the code below i get, it is presented but the console shows "Warning: Attempt to present <UIActivityViewController: 0x7f8788e7aed0> on <MyApp.CustomTableViewController: 0x7f8788e3db60> which is already presenting (null)".

@IBAction func shareImage(sender: AnyObject) {
    let images: [UIImage] = [image.image!]
    let activityViewController = UIActivityViewController(activityItems: images, applicationActivities: nil)
    self.presentViewController(activityViewController, animated: true, completion: nil)
}

此函数由 UILongPressGestureRecognizer 调用.请注意,我正在使用具有以下层次结构的故事板:

This func is called by an UILongPressGestureRecognizer. Note that i'm using storyboard with the following hierarchy:

TabBarController > (Relationship) > NavigationController > (Relationship) > TableViewController > (Show) > TableViewController> (Show) > ViewController.

TabBarController > (Relationship) > NavigationController > (Relationship) > TableViewController > (Show) > TableViewController > (Show) > ViewController.

展示发生在最后一个 ViewController 上.

The presentation happens on the last ViewController.

我很确定这是关于层次结构的,哪个控制器当前正在呈现(也许是如何呈现)以及哪个控制器负责呈现 UIActivityViewController.

I'm quite sure it's about the hierarchy, which controller is currently presenting (and maybe how) and which controller is responsible for presenting the UIActivityViewController.

编辑

UILongPressGestureRecognizer 多次调用导致警告的触摸事件

UILongPressGestureRecognizer touch event is called multiple times which was causing the warning

推荐答案

从您的问题中很难说清楚,但在发生这种情况时是否存在其他一些视图控制器?例如和行动表或其他?

It's hard to say from your question but is there some other view controller presented at the moment this happens? for example and action sheet or other?

无论如何试试这个:

    if self.presentedViewController != nil {
        self.dismissViewControllerAnimated(false, completion: {
            [unowned self] in
            self.presentViewController(activityViewController, animated: true, completion: nil)
            })
    }else{
        self.presentViewController(activityViewController, animated: true, completion: nil)
    }

这篇关于呈现 UIActivityViewController 时的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆