gpt4 book ai didi

ios - swift - 警告 : Attempt to present * on * while a presentation is in progress

转载 作者:可可西里 更新时间:2023-11-01 01:42:33 26 4
gpt4 key购买 nike

由于这个错误,我无法切换到另一个 View Controller 。我想在成功扫描二维码后切换到另一个 View Controller 。

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!

我的代码

@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)
}
}

P.S:我正在使用 QRCodeReader 插件,https://github.com/yannickl/QRCodeReader.swift .

最佳答案

您能否在阅读器(QRCodeReader)被关闭后尝试显示模态视图 Controller 。文档中有一个名为 didScanResultQRCodeReader 回调。

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)

})
}

reader.completionBlock 中删除代码。

关于ios - swift - 警告 : Attempt to present * on * while a presentation is in progress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28183940/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com