2014-10-07 92 views
1

我正在嘗試解析和Swift。 我想在登錄成功後隱藏登錄視圖。用swift登錄解析框架

我在方法logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!)中使用了dismissViewControllerAnimated,但它無法顯示下一個viewController。

OS:MacOSX的10.9.4 的Xcode 6.1β2

class LoginViewController: UIViewController, 
         PFLogInViewControllerDelegate, 
         PFSignUpViewControllerDelegate { 

    override func viewDidAppear(animated: Bool) { 
     //Create Login 
     var loginViewController:PFLogInViewController = PFLogInViewController() 
     loginViewController.fields = PFLogInFieldsDefault 
     presentViewController(loginViewController, animated: true, completion: nil) 
     loginViewController.delegate = self 
     loginViewController.signUpController.delegate = self 
    } 

    override func viewDidLoad() { 
     super.viewDidLoad() 
    } 

    func logInViewController(logInController: PFLogInViewController!, 
          didLogInUser user: PFUser!) 
    { 
     logInController.dismissViewControllerAnimated(true, completion: nil) 
     //var nextViewController:RegisterViewController = RegisterViewController() 
     //presentViewController(nextViewController, animated: true, completion: nil) 
    } 
} 

如何隱藏loginViewController和顯示下一個視圖控制器?

+0

你試過self.dismissViewControllerAnimated(true,completion:nil)嗎? – Andrew 2014-10-07 13:31:33

+0

self.dissmissViewControllerAnimated(true,completion:nil)不起作用。 LoginViewController仍然顯示。 – tajihiro 2014-10-07 13:41:58

+0

可能重複[在Facebook登錄後將問題推送到PFQueryTableViewController](http://stackoverflow.com/questions/15102770/trouble-pushing-to-pfquerytableviewcontroller-after-facebook-login) – 2014-10-07 13:47:15

回答

0

你試過:

func logInViewController(logInController: PFLogInViewController!, 
         didLogInUser user: PFUser!) 
{ 
    var nextViewController = RegisterViewController() 
    self.presentViewController(nextViewController, animated: true, completion: nil) 
} 
0

我知道這是一個老問題。你所做的就是關閉當前的VC,然後在完成塊中顯示NextViewController。

func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) 

    logInController.dismissViewControllerAnimated(true, completion: {() -> Void in 
     var nextVC = NextViewController() 
     self.presentViewController(nextVC, animated: true, completion: nil) 
    }) 

}