【发布时间】:2016-10-01 00:11:15
【问题描述】:
如果用户需要登录才能访问某项功能,我会尝试向用户显示警报,但是当我按下警报中的登录按钮时,self.self.performSegueWithIdentifier("tryonToLogin", sender:self) 似乎没有做任何事情。
LoginViewController
@IBAction func unwindToLogin(segue:UIStoryboardSegue){
}
UIAlert
@IBAction func goToGallery(sender: UIButton){
if(isLoggedIn){
performSegueWithIdentifier("ShowGallery", sender: sender)
}else{
showMessage("You must login to view access this feature", sender:sender)
}
}
func showMessage(popUpMessageText : String, sender:UIButton){
let messageTitle = "Error"
print("prepreform segue")
performSegueWithIdentifier("unwindToLogin", sender:sender)
let refreshAlert = UIAlertController(title: messageTitle, message: popUpMessageText, preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction( UIAlertAction(title: "Login", style: .Default, handler: { (action: UIAlertAction!) in
print("Handle Login redirect logic here")
self.performSegueWithIdentifier("unwindToLogin", sender: self)
print("after Handle Login redirect logic here")
}))
refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in
print("Handle Cancel logic here")
}))
presentViewController(refreshAlert, animated: true, completion: nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
print("prepare for segue called")
self.camera = nil
}
没有错误。它被调用,好像 ii 放入一个不存在的 id 我得到 no segue with specified identifier found 错误消息。
UIAlert 是否影响performSegueWithIdentifier()的调用
下面的帖子使用了这种方法,所以我认为它应该可以工作。我错过了什么。
**IB 截图**
编辑
我尝试移动 self.performSegueWithIdentifier("unwindToLogin", sender:self) 以查看确实出现了,但它仍然无法正常工作。
【问题讨论】:
-
你最终让它工作了吗?我也不能让它工作。
-
@bibscy 不幸的是我不记得解决方案,并且不再可以访问该项目
标签: ios swift uialertcontroller unwind-segue