在我的HomeViewController中,我有两个segue,一个单击时激活单元格,一个单击条形按钮项目时单击join list
。当单击栏按钮项目时,我想检查用户是否已登录。如果用户没有登录,我想让LoginViewController接口出现,如果他登录了,我想让joinViewController的接口出现。我从参加INTEM到joinViewController按住Ctrl创建从故事板的连接SEGUE,这是我的代码快速关闭视图
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "detail" {
var detailScene=segue.destinationViewController as! DetailViewController
if let indexPath=self.table.indexPathForSelectedRow{
let selectedPerson=listPerson[indexPath.row]
detailScene.person=selectedPerson
}}
else
if segue.identifier == "join"{
if !userLoggedIn{
let vc : AnyObject! = self.storyboard!.instantiateViewControllerWithIdentifier("LoginViewController")
self.presentViewController(vc as! UIViewController, animated: true, completion: nil)
}
}
}
一切工作正常,但在LoginViewController我说,IBAction为你关闭该视图
class LoginViewController: UIViewController {
@IBAction func dismissView(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
当按钮被点击时,加载joinViewController而不是homeViewControlled。我做了干净的工作,我该如何解决解雇按钮?
你可以尝试在你的'HomeViewController'中重写'shouldPerformSegueWithIdentifier'并在那里移动登录逻辑。如果未登录,则返回'false',否则返回true。希望这可以帮助。 – riik