错误“[ShareSheet] 连接无效"错误 iOS13+ 但不在 iOS 11.4 上 [英] Error "[ShareSheet] connection invalidated" error iOS13+ but not on iOS 11.4

查看:41
本文介绍了错误“[ShareSheet] 连接无效"错误 iOS13+ 但不在 iOS 11.4 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用共享表共享一个文件,并编写了看起来工作正常的代码.但是我一直在日志中看到这些错误消息(使用 Xcode 11.3)

I want to share a file using the Share Sheet and have written code that seems to work just fine. However I keep seeing these error messages in the log (using Xcode 11.3)

[ShareSheet] connection invalidated

我正在测试两个物理设备;运行 iOS 13.1.2 的 iPad 和运行 11.4 的 iPhone 6.我在装有旧版 iOS 的 iPhone 上看不到这些消息.在这两种情况下,共享似乎都可以正常工作.这是我使用文本而不是文件的代码:

I have two physical devices I'm testing on; an iPad running iOS 13.1.2 and an iPhone 6 running 11.4. I don't see these messages on the iPhone with the older iOS on it. Both cases the sharing seems to work just fine. Here's the code I'm using using text instead of a file:

let activityViewController = UIActivityViewController(activityItems: ["simple text for test"], applicationActivities: nil)
activityViewController.excludedActivityTypes = [.message, .airDrop]
activityViewController.popoverPresentationController?.barButtonItem = myBarButtonItem           
self.present(activityViewController, animated: true, completion: nil)

当共享表消失时,该消息会显示(因为用户完成了一个操作,或者他们在操作之外点击以取消).

The message shows up when the share sheet goes away (either because user completes an action, or they tap outside of it to cancel).

忽略这些消息是否安全?奇怪的是,它们没有出现在旧操作系统中,但出现在新操作系统中.

Is it safe to ignore these messages? It's just odd that they didn't show up in the older OS but do in the new one.

2020 年 3 月 20 日我确认我提供了有效的来源或 barButtonItem.我已经更改了代码以匹配我使用 UIBarButtonItem 的地方,但我仍然看到 ShareSheet 连接无效错误.

Edited on 20 Mar 2020: I validated that I was providing a valid source or barButtonItem. I've changed the code to match that where I'm using a UIBarButtonItem and I still see the ShareSheet connection invalidated error.

推荐答案

我得到了

[ShareSheet] 连接失效

[ShareSheet] connection invalidated

在 iOS 13.x 上的 Xcode 输出日志中,共享表被压扁,其中没有任何按钮.

in the Xcode output log on iOS 13.x, and the share sheet was squished and did not have any buttons in it.

要修复它,请将您的 sourceView 分配给比 self.view

To fix it, assign your sourceView to something more specific than self.view

就我而言,我的视图顶部附近有一些 UILabels,因此我将 sourceView 设置为其中之一.例如,在我的父视图控制器中,我有一个名为 labelCustomerNameUILabel 所以我使用了它:

In my case, I had some UILabels near the top of my view, so I set my sourceView to one of those. For example, in my parent view controller, I had a UILabel named labelCustomerName so I used that:

activityViewController.popoverPresentationController?.sourceView = self.labelCustomerName

这篇关于错误“[ShareSheet] 连接无效"错误 iOS13+ 但不在 iOS 11.4 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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