ios - 使用 Swift 解析登录

标签 ios authentication swift parse-platform

我正在使用 swift 和 Parse 为我的 ios 应用程序创建一个登录页面。在我的初始 View Controller 中,我有

var user = PFUser.currentUser()
if user != nil {
  println(user)
  self.dismissViewControllerAnimated(1, completion: nil)
} else {
  println("No Logged in user")
  var login: PFLogInViewController = PFLogInViewController()
  login.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton |        PFLogInFields.SignUpButton
  self.presentViewController(login, animated: true, completion: nil)
}

在我想在登录后转到的 ViewController 的 viewDidLoad 方法中。登录屏幕最初出现,然后我可以输入我的信息,但如果我输入正确的登录信息,它不会去任何地方。从那时起,重新启动应用程序允许我登录。我希望无需重新启动应用程序即可登录,但不知道如何执行此操作。

最佳答案

你只需要实现

- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
    [self dismissViewControllerAnimated:YES completion:NULL];
}

当 PFUser 登录时调用。

在 Swift 中

func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) -> Void{
    self.dismissViewControllerAnimated(true, completion: nil)
}

关于ios - 使用 Swift 解析登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26306367/

相关文章:

ios - Grails多部分服务流意外结束

ios - 异步调用的空闭包

node.js - 确认另一个系统上的用户

ios - iOS 10 中 iMessage 扩展中导航栏后面可见的 Collection View

ios - 如何使用 UIImagePickerController 相机图像来更新我的 UICollectionViewCell?

ios - UILabel 没有响应触摸事件

swift - 我该如何解决这个错误? : "use of unimplemented initializer ' init( )' for class"

json - Swift - Alamofire - 解析 JSON

php - 正在做 CakePHP Acl 教程。我似乎无法填充 aros_acos

android - 如何克服android twitter认证异常(401)?