I'm trying to present a view controller once the QRCode reader has been dismissed, however when doing this the QRCode reader view controller is presented again. The code snippet below shows the method and how I'm dismissing the view and how I'm trying to present the next view controller. Any idea on why the QR reader view controller keeps presenting its self when I try to present a different controller.
func readerDidCancel(_ reader: QRCodeReaderViewController) {
dismiss(animated: true, completion: nil)
present(ClockInOrOutViewController(), animated: true, completion: nil)
}
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?)