在 iOS 14 上,当用户在另一个应用程序上复制/粘贴内容时,会显示一条通知,其中包含粘贴板内容来自的应用程序的名称:
是否可以以编程方式获取此信息?
例如,如果用户在 Safari 上复制链接并将其粘贴到我的应用程序中,应用程序是否可以知道粘贴板内容来自 Safari ?
我在 UIPasteboard 或 UIPasteConfiguration 文档中没有找到类似的内容。
最佳答案
似乎没有 API 来获取 owner
谁把元素放在 pasteboard
.
来自 documentation :
Pasteboard Owner and Items
The object that last put data onto the pasteboard is referred to as the pasteboard owner. Each piece of data placed onto a pasteboard is considered a pasteboard item. The pasteboard can hold single or multiple items. Apps can place or retrieve as many items as they wish. For example, say a user selection in a view contains both text and an image. The pasteboard lets you copy the text and the image to the pasteboard as separate items. An app reading multiple items from a pasteboard can choose to take only those items that it supports (the text, but not the image, for example).
addItems方法,没有(或者我可能找不到)任何名为
owner
的属性.
关于ios - 如何以编程方式获取 iOS 上粘贴板内容的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65882735/