简体   繁体   English

Swift - 警告:在演示过程中尝试在 * 上演示 *

[英]Swift - Warning: Attempt to present * on * while a presentation is in progress

I can't switch to another view controller because of this error.由于此错误,我无法切换到另一个视图控制器。 I want to switch to another view controller after it successfully scan the QR code.我想在成功扫描二维码后切换到另一个视图控制器。

2015-01-27 17:59:16.093 *[5416:1860144] Warning: Attempt to present <*.SuccessViewController: 0x144e38a20> on <*.MethodViewController: 0x144e2b960> whose view is not in the window hierarchy!

My code我的代码

@IBAction func btnQrCode(sender: AnyObject) { 
    reader.modalPresentationStyle = .FormSheet
    reader.delegate               = self

    reader.completionBlock = { (result: String?) in
    if result != nil {
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

        let successViewController = storyBoard.instantiateViewControllerWithIdentifier("successView") as SuccessViewController
        self.presentViewController(successViewController, animated:true, completion:nil)

    }

    presentViewController(reader, animated: true, completion: nil)
    }
}

PS: I'm using QRCodeReader plugin, https://github.com/yannickl/QRCodeReader.swift . PS:我正在使用 QRCodeReader 插件, https://github.com/yannickl/QRCodeReader.swift

Can you try showing the modal view controller after the reader(QRCodeReader) has been dismissed.您可以尝试在阅读器(QRCodeReader)被解散后显示模态视图控制器。 There is a callback for QRCodeReader called didScanResult in the documentation.有一个回调QRCodeReader称为didScanResult的文件中。

https://github.com/yannickl/QRCodeReader.swift https://github.com/yannickl/QRCodeReader.swift

func reader(reader: QRCodeReader, didScanResult result: String) {
   self.dismissViewControllerAnimated(true, completion: { () -> Void in

       // use the result variable here.

        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
        let successViewController = storyBoard.instantiateViewControllerWithIdentifier("successView") as SuccessViewController
        self.presentViewController(successViewController, animated:true, completion:nil)

   })
}

Remove the code from reader.completionBlock .reader.completionBlock删除代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在演示过程中尝试呈现 UIViewController!-警告 - Attempt to present UIViewController while a presentation is in progress!-Warning 警告:在演示文稿正在进行时尝试显示uiimagepickercontroller - Warning: Attempt to present uiimagepickercontroller while a presentation is in progress 警告:尝试呈现 - Warning: Attempt to present <UINavigationController while a presentation is in progress 是否可以忽略“警告:在演示过程中尝试演示……”是否安全? - Is it safe to ignore “Warning: Attempt to present … while presentation in progress”? performSegue导致在演示过程中出现警告尝试 - performSegue causes Warning Attempt to present while a presentation is in progress iOS:警告:尝试出席 <ModalViewController> 上 <ViewController> 演示文稿正在进行中 - iOS: Warning: Attempt to present <ModalViewController> on <ViewController>while a presentation is in progress ios7-警告:在进行演示时尝试在UINavigationController上呈现UINavigationController - ios7 - Warning: Attempt to present UINavigationController on UINavigationController while a presentation is in progress 在演示过程中尝试在UITabBarController上呈现UIImagePickerController - Attempt to present UIImagePickerController on UITabBarController while a presentation is in progress Xcode5错误:警告尝试呈现 <View> 上 <OtherView> 在进行演示时 - Xcode5 error : Warning attempt to present <View> on <OtherView> while presentation is in progress iOS:无法在AppBrowser中启动cordova-&gt;“警告:尝试演示 <inAppBrowser> 上 <MainViewController> 在演示过程中” - iOS: Can't start cordova inAppBrowser -> “Warning: Attempt to present <inAppBrowser> on <MainViewController> while a presentation is in progress”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM