gpt4 book ai didi

ios - 在 Swift 2.2 中呈现弹出窗口时在闭包错误中隐式使用 'self'

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

如果用户成功重置密码,我会尝试将 View Controller 呈现为弹出窗口。基本上,如果通过电子邮件发送密码重置说明电子邮件一切正常,那么将运行以下代码。但是,我收到了错误

闭包中“self”的隐式用户;使用“.self”使捕获语义明确

在下面的第一行:

    let VC = storyboard?.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as! ResetPasswordSuccessPopOverViewController
VC.preferredContentSize = CGSize(width: UIScreen.mainScreen().bounds.width, height: 100)
let navController = UINavigationController(rootViewController: VC)
navController.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = navController.popoverPresentationController
popover?.delegate = self

self.presentViewController(navController, animated: true, completion: nil)

最佳答案

试试这个

let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as ResetPasswordSuccessPopOverViewController

或者试试这个

  let viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as ResetPasswordSuccessPopOverViewController

关于ios - 在 Swift 2.2 中呈现弹出窗口时在闭包错误中隐式使用 'self',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38345686/

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