首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIPasteboard在后台返回零

UIPasteboard在后台返回零
EN

Stack Overflow用户
提问于 2019-02-01 17:40:50
回答 1查看 842关注 0票数 1

我试着在applicatioDidEnterBackground的AppDelegate部分读了5遍。要打印字符串,我使用print(UIPasteboard.general.string!),但它只在函数中工作,在其他嵌套函数中不起作用。让我解释一下:

代码语言:javascript
复制
func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    print(UIPasteboard.general.string!) //here it works perfectly and prints the string correctly

    for _ in 0...5 {
       print(UIPasteboard.general.string!) //here it returns nil 
    }

}

我读过其他类似于矿井的问题,但没有人帮助我。我不知道这是不是安全限制,但如果你能帮我,我会很感激

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-01 17:49:10

iOS 9将UIPasteboard更改为不允许后台访问:

据推测,他们做出这一改变是为了防止后台应用程序监视你的纸板内容。有时,人们会使用黑板将密码从一个应用程序复制到另一个应用程序,因此阻止后台pasteboard访问是一个安全问题。

另外,一些应用程序(比如Facebook)可以收集尽可能多的关于用户的数据,同时比苹果的隐私政策宽松得多。阻断背景面板访问是降低Facebook监视非Facebook活动能力的一种方法。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54484540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档