我试图在用户成功重置密码时将视图控制器显示为弹出窗口。基本上,如果通过电子邮件发送密码重置指令电子邮件都可以,那么将运行以下代码。但是,我收到了错误
封闭中“自我”的隐含用户;使用'.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
在Swift中,捕获的自引用的语义不允许是显式的,因此引用闭包内的对象的任何成员都需要您显示您对self.
被明确添加到引用标识符的捕获的完全承诺。
let VC = self.storyboard?.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as! ResetPasswordSuccessPopOverViewController
请注意self.
之前的storyboard?.
。