是否可以隐藏NFC阅读会话的iOS系统警报 [英] Is it possible to hide iOS system alert for NFC reading session
问题描述
成功完成NFC
阅读会话后,您会看到类似的内容:
When you successfully finish an NFC
reading session you'll see something like that:
这将覆盖当前显示的ViewController
大约3秒钟.有趣的是,这种行为是不一致的,因为如果阅读会话完成得非常快,此窗口将立即消失.
This will overlay the currently presented ViewController
for about 3 seconds. The fun part is that this behaviour is inconsistent since this window will disappear immediately if the reading session finish very fast.
这意味着我不能确定此覆盖层将保留多长时间,以确保对我们的应用的UX设计不利.
It means that I cannot be sure about how long will this overlay stay for sure which is bad for our app's UX design.
问题很简单:是否有一种方法可以强制此叠加消失或至少处理消失的事件(不是完成NFC
会话时的事件)?
The question is simple: is there a way to force this overlay to disappear or at least to handle the event of when it disappears (not when the NFC
session if finished)?
推荐答案
我发现了一种有趣的隐藏窗口的方法.需要两个简单的步骤:
I've found an interesting way to hide that window. 2 simple steps are required:
1)初始化阅读器会话时,将最后一个参数设置为false:NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: false)
1) When initialising your reader session set the last parameter to false: NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: false)
2)在readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage])
的正文中,您应该调用session.invalidate()
.
2) In the body of readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage])
your should call session.invalidate()
.
就是这样.就像您点按取消/完成"一样-系统窗口将立即消失.
That's it. It will work as if you tapped Cancel/Done - the system window will disappear immediately.
这篇关于是否可以隐藏NFC阅读会话的iOS系统警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!