一旦QRCode阅读器被关闭,我正在尝试提供一个视图控制器,但是这样做时,QRCode阅读器的视图控制器会再次出现。下面的代码片段显示了该方法以及如何关闭视图以及如何呈现下一个视图控制器。当我尝试展示其他控制器时,为什么QR阅读器视图控制器会不断展示自己的想法。
[
{
"lat": 43.96063343238712,
"panoid": "sffcNG69c2kdZwEuYp1htw",
"lon": 3.098330084924494,
"calc": -6.0393665676128805
},
{
"lat": 43.96052745649745,
"panoid": "2rJPv_r0gC5FBPLZK5vHDA",
"lon": 3.098487422195691,
"calc": -6.039472543502548
}
]
答案 0 :(得分:1)
You have to call the present
inside the completion handler of the dismiss
.
func readerDidCancel(_ reader: QRCodeReaderViewController) {
weak var presentingViewController = self.presentingViewController
self.dismiss(animated: true, completion: {
presentingViewController?.present(ClockInOrOutViewController(), animated: true, completion: nil)
})
}
If this does not work, it means your presenting view controller has also been removed somehow. (dismissed/popped?)
答案 1 :(得分:0)
You can't present view controller while other view controller is dismissing and also present on dismissing view controller. You can do something like this:
func readerDidCancel(_ reader: QRCodeReaderViewController) {
let presenting = self.presentingViewController
dismiss(animated: true, completion: {
presenting?.present(ClockInOrOutViewController(), animated: true, completion: nil)
})
}