我有一个简单的二维码扫描仪(使用Avfoundation)。当检测到二维码时,它将停止捕获并通过扫描仪视图控制器(不是全屏)显示信息视图控制器。但是,当我关闭信息视图控制器时,就无法再次开始捕获(不调用外观方法)。有任何解决方法的想法吗?
控制器A呈现控制器B:
let sb = UIStoryboard(name: "customViewAlert", bundle: nil)
let vc = sb.instantiateInitialViewController()!
vc.modalTransitionStyle = .crossDissolve
vc.modalPresentationStyle = .overCurrentContext
present(
vc,
animated: true,
completion: nil
)
控制器A委派:
extension ViewController: ModalHandler {
func modalDismissed() {
self.captureSession.startRunning()
}
}
控制器B关闭:
@IBAction func closeButtonTap(_ sender: Any) {
delegate?.modalDismissed()
dismiss(
animated: true,
completion: nil
)
}
答案 0 :(得分:0)
您需要设置代表
let vc = sb.instantiateInitialViewController()!
vc.delegate = self