UIPasteboard顽固地坚持,无论我做什么
我正在创建一个应用程序 UIPasteboard,并按照文档中的建议使用我的应用程序标识符作为名称(例如 com.example.app.pboard)。
所有的复制和粘贴都有效,但该死的东西永远不会消失。每次访问它以将某些内容复制到其上时,我都会将其 persistent
属性显式设置为 NO,甚至每次我的应用程序启动时都会调用 UIPasteboard 的 +removePasteboardWithName:
。
但每次我查看它时,尽管应用程序重新启动,我复制到它上面的最新内容始终都在那里。
什么给?
I am creating a application UIPasteboard with my app's identifier as a name (e.g. com.example.app.pboard) as suggested in the docs.
All the copying and pasting works, but the damn thing never goes away. I set its persistent
property explicitly to NO every time I access it to copy something onto it, and I even call UIPasteboard's +removePasteboardWithName:
every time my app starts.
But every time I look at it, the most recent thing I copied onto it is always there, despite app restarts.
What gives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道为什么您正在尝试的方法不起作用,这里有两个猜测和一个可能的解决方案:
您也许可以通过在离开或进入应用程序时将粘贴板的
items
设置为 nil 来解决此问题。No idea why what you are trying isn't working, here are two guesses and a possible solution:
You could perhaps solve this by setting the pasteboard's
items
to nil when leaving or entering the app.您可以将 UIPasteboard 设置为持久。根据Apple的文档,
更新:对于 iOS 10,UIPasteboard 自动设置持久性。
You can set UIPasteboard to persistent. Accord to Apple's document,
Update: For iOS 10, UIPasteboard set persistence automatically.