一般的 iPhone 粘贴板会包含多个项目吗?

发布于 2024-07-27 21:05:25 字数 511 浏览 8 评论 0原文

pasteboard.numberOfItems(在下面的代码中)是否会大于 1? 用户将如何导致这种情况发生?

UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
pasteBoard.numberOfItems

请注意,我并不是在问单个粘贴板项目是否可以有多个表示类型。 他们可以做到这一点是显而易见的。

更新:我知道以编程方式可以在粘贴板中放置多个项目(使用 addItems 作为 Kevin Ballard 指出,或者通过将 items 属性设置为包含多个字典的数组)。 但用户可以使用任何内置应用程序来执行此操作吗? 我想人们可以轻松地编写一个应用程序,将多个项目放入粘贴板中(因此,为了使我的应用程序健壮,它应该处理这种情况)。

Would pasteboard.numberOfItems (in the code below) ever be greater than 1? How would the user cause this to happen?

UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
pasteBoard.numberOfItems

Note that I'm not asking if a single pasteboard item can have more than one representation type. That they can is clear.

Update: I understand that programmatically one could put more than one item in the pasteboard (using addItems as Kevin Ballard points out, or by setting the items property to an array containing more than one dictionary). But could the user do this using any of the built-in apps? I suppose one could easily write an app that puts more than one item in the pasteboard (so for my app to be robust, it should handle that situation).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

娇纵 2024-08-03 21:05:25

UIPasteboard 上有一个 -addItems: 方法,所以我认为很明显,肯定可以有多个项目。

There's an -addItems: method on UIPasteboard, so I think it's pretty clear that it's certainly possible to have multiple items.

心意如水 2024-08-03 21:05:25

不适用于 Apple 提供的应用程序。 据我所知,第三方应用程序完全有可能添加多个项目。

编辑:再想一想,我在测试我的应用程序时可能多次拥有多个项目,但我无法确定它来自哪里,或者是否是 Apple 应用程序。 无论哪种情况,我都会为其编写一个测试。 我的应用程序 - 现在 - 仅查看第一项,并且我在测试中从未遇到过内置应用程序的问题。

Not with Apple's provided apps. It's entirely possible for a third party app to add multiple items as far as I know.

EDIT: On second thought, I may have had multiple items a few times while testing my app, but I didn't determine from where, or whether it was an Apple app. In either case, I'd write a test for it. My app -- right now -- only looks at the first item, and I've never had problems with built in apps in testing.

感情洁癖 2024-08-03 21:05:25

内置的照片应用程序允许您将多张照片放置在通用粘贴板上。 只需使用“共享”按钮,选择多张照片,然后按“复制”即可。

然后,通用粘贴板会将每张照片作为具有两种表示形式的项目:“public.jpeg”和“public.utf8-plain-text”。 第二个表示形式(文本)似乎是一个文件名,但在这种情况下,照片始终返回“图像”加上序列号(即 image1.jpg、image2.jpg 等)。

此外,用户可以使用剪贴板应用程序(其中一些存在于应用程序商店中)将多个项目放置在通用粘贴板中。 我目前正在构建一个剪贴板共享应用程序。

The built-in Photos app allows you to place multiple photos on the general pasteboard. Just use the "Share" button, select several photos, and then press "Copy".

The general pasteboard will then have each photo as an item with two representations: "public.jpeg" and "public.utf8-plain-text". The second representation (text) seems to be a file name, however in this case Photos always returns "image" plus a sequential number (i.e. image1.jpg, image2.jpg, etc.).

In addition, the user may use a clipboard app (several of which are present in the App store) to place multiple items in the general pasteboard. I'm currently building a clipboard sharing app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文