ios - 如何以编程方式获取 iOS 上粘贴板内容的来源

标签 ios swift uipasteboard

在 iOS 14 上,当用户在另一个应用程序上复制/粘贴内容时,会显示一条通知,其中包含粘贴板内容来自的应用程序的名称:
On this example, the text is pasted to Notes app from Safari app
是否可以以编程方式获取此信息?
例如,如果用户在 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/

相关文章:

ios - 如何在 SwiftUI 中实现触发 switch case 的左或右 DragGesture() ?

iphone - 我可以获取 iOS UIPasteboard 的所有名称吗?

android - 火力基地 : How to Check Count of Users on a Specific App Version from Firebase Console

ios - iOS 中的十六进制颜色不准确

ios - 压缩视频的尺寸/秒转换率是多少

ios - 错误: Expression resolves to an unused function (array with closure)

multithreading - 从后台线程 SWIFT 更新 UI

ios - 上一个/下一个 类似 iOS 邮件应用程序的功能吗?

iPhone iOS 如何通过长按将图像粘贴到 UIImageView 中

ios - 防止 uitextfield 粘贴非数字字符串