为啥程序在登录时不执行segue?
Posted
技术标签:
【中文标题】为啥程序在登录时不执行segue?【英文标题】:Why is the program not performing segue when logged in?为什么程序在登录时不执行segue? 【发布时间】:2015-10-26 17:09:22 【问题描述】:我有一个登录屏幕,如果单击登录按钮时凭据正确,则将执行 segue。 segue 具有正确的标识符,并且用户已登录,因为我正在通过 currentUser 传递数据,并且它显示在控制台中,表明用户已登录,但未执行 segue。为什么?下面是我的登录代码。
@IBAction func loginAction(sender: AnyObject)
let username = self.usernameField.text
let password = self.passwordField.text
if(username!.utf16.count) < 4 || (password!.utf16.count < 5)
let alert = UIAlertView(title: "Invalid", message: "Username must be greater then 4 and Password must be greater then 5", delegate: self, cancelButtonTitle: "OK")
alert.show()
else
self.actInd.startAnimating()
PFUser.logInWithUsernameInBackground(username!, password: password!, block: (user, error) -> Void in
self.actInd.stopAnimating()
if ((user) != nil)
var alert = UIAlertView(title: "Success", message: "Logged In", delegate: self, cancelButtonTitle: "OK")
alert.show()
self.performSegueWithIdentifier("login", sender: self)
else
let alert = UIAlertView(title: "Error", message: "\(error)", delegate: self, cancelButtonTitle: "OK")
alert.show()
)
【问题讨论】:
【参考方案1】:您正在后台线程上调用 performSegueWithIdentifier。 尝试用
包装它dispatch_async(dispatch_get_main_queue(),
)
【讨论】:
我收到一个错误2015-10-26 12:21:24.909 Musec[63427:654722] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This query has an outstanding network connection. You have to wait until it's done.
我发现了问题所在,它与其他问题有关。以上是关于为啥程序在登录时不执行segue?的主要内容,如果未能解决你的问题,请参考以下文章
为啥我的 UITableView 不执行 show segue,只显示模态
如何从流程中间执行导航 [segue] + ios 应用程序