我正在使用 parse 为其最新的 ParseUI 提供的登录代码。我很困惑为什么我每次使用 self.logInViewController
和 self.signUpViewController
时都会收到此错误,错误是:
Ambiguous reference to member 'logInViewController' and 'signUpViewController'
这是我的代码:
import Parse
import ParseUI
import UIKit
class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate {
@IBAction func simpleAction(sender: AnyObject) {
self.presentViewController(self.logInViewController, animated: true, completion: nil)
}
@IBAction func customAction(sender: AnyObject) {
self.performSegueWithIdentifier("custom", sender: self)
}
@IBAction func logoutAction(sender: AnyObject) {
PFUser.logOut()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if (PFUser.currentUser() == nil) {
self.logInViewController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton
var logInLogoTitle = UILabel()
logInLogoTitle.text = "Parse"
self.logInViewController.logInView.logo = logInLogoTitle
self.logInViewController.delegate = self
var SignUpLogoTitle = UILabel()
SignUpLogoTitle.text = "Parse"
self.signUpViewController.signUpView.logo = SignUpLogoTitle
self.signUpViewController.delegate = self
self.logInViewController.signUpController = self.signUpViewController
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func logInViewController(logInController: PFLogInViewController!, shouldBeginLogInWithUsername username: String!, password: String!) -> Bool {
if (!username.isEmpty || !password.isEmpty) {
return true
}else {
return false
}
}
func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func logInViewController(logInController: PFLogInViewController!, didFailToLogInWithError error: NSError!) {
print("Failed to login...")
}
func logInViewControllerDidCancelLogIn(logInController: PFLogInViewController!) {
}
func signUpViewController(signUpController: PFSignUpViewController!, didSignUpUser user: PFUser!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func signUpViewController(signUpController: PFSignUpViewController!, didFailToSignUpWithError error: NSError!) {
print("FAiled to sign up...")
}
func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController!) {
print("User dismissed sign up.")
}
}
最佳答案
logInViewController
和 signUpViewController
都未定义。
您需要定义它们:
let logInViewController = PFLogInViewController()
let signUpViewController = PFSignUpViewController()
关于ios - 解析登录 self.logInViewController 对成员 ' logInViewController' 的模糊引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34375935/