We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一个不靠谱并且要弹一次窗的办法,但是能用:
计算获取 UIPasteboard.general.string 花了多长时间。
UIPasteboard.general.string
如果已经允许,那么通常在16ms,也就是一帧的时间内完成。有时候也两帧三帧。 而如果是询问,则通常需要1s或更久。
所以,通过这个时间差,就可以猜测出是否已经授权。
办法是土办法,但是能用,取决于你想要什么样的交互。
// 抽象检测方法 private func checkPastePermission() -> Bool { let startTime = DispatchTime.now() _ = UIPasteboard.general.string let milliseconds = Double(DispatchTime.now().uptimeNanoseconds - startTime.uptimeNanoseconds) / 1_000_000 print("剪贴板访问耗时: \(String(format: "%.2f", milliseconds))ms") // 16*5 5帧 return milliseconds < 16 * 5 }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一个不靠谱并且要弹一次窗的办法,但是能用:
计算获取
UIPasteboard.general.string
花了多长时间。如果已经允许,那么通常在16ms,也就是一帧的时间内完成。有时候也两帧三帧。
而如果是询问,则通常需要1s或更久。
所以,通过这个时间差,就可以猜测出是否已经授权。
办法是土办法,但是能用,取决于你想要什么样的交互。
The text was updated successfully, but these errors were encountered: