Parse-SDK-iOS-OSX
Parse-SDK-iOS-OSX copied to clipboard
PFSignUpViewController Additional Field
I'm trying to capture users' full names at sign up. I've subclassed PFSignUpViewController and in viewDidLoad() I have the following:
self.fields = [.usernameAndPassword, .dismissButton, .signUpButton, .additional]
However when the SignUpViewController loads, only the username & password fields show up. I am able to make other customizations (button colors, background and logo images, etc.). At runtime, signUpView.additionalField is nil.
I also tried forcing the additional field to be enabled using
signUpView.additionalField.isEnabled = true
but this did not change anything. Interestingly, if I do this:
self.fields = [.dismissButton, .signUpButton, .additional]
The username and password fields still show up and the rawValue of signupView.fields does not change (the rawValue is 27 regardless of what I include in the fields array).
There isn't much documentation around this, so any help that can be provided would be awesome (and should probably be added to the documentation for future use).
Thank you
Can you share your full PFSignUpViewController
configuration? - I can’t replicate this right now
Sure,
I have a very simple subcalsss of PFSignUpViewController:
import UIKit
import Parse
class SignUpViewController : PFSignUpViewController {
var backgroundImage : UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.emailAsUsername = true
self.modalTransitionStyle = .flipHorizontal
self.fields = [PFSignUpFields.usernameAndPassword, PFSignUpFields.dismissButton, PFSignUpFields.signUpButton, PFSignUpFields.additional]
signUpView?.additionalField?.placeholder = "Full Name"
signUpView?.additionalField?.isEnabled = true
let nameField = PFTextField(frame: CGRect(x: 0, y: signUpView!.signUpButton!.frame.origin.y + signUpView!.signUpButton!.frame.height + 16.0, width: signUpView!.usernameField!.frame.width, height: signUpView!.usernameField!.frame.height))
signUpView?.insertSubview(nameField, at: 1)
backgroundImage = UIImageView(image: UIImage(named: "bg"))
backgroundImage.contentMode = .bottom
signUpView?.insertSubview(backgroundImage, at: 0)
signUpView?.signUpButton!.setBackgroundImage(nil, for: .normal)
signUpView?.signUpButton!.backgroundColor = Constants.orangeColor
signUpView?.dismissButton!.setTitle("Already signed up?", for: .normal)
signUpView?.dismissButton!.setImage(nil, for: .normal)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
backgroundImage.frame = signUpView!.frame
signUpView!.logo = UIImageView(image: UIImage(named: "logo"))
signUpView!.logo!.frame = CGRect(x: 0, y: 200, width: signUpView!.frame.width, height: 113)
signUpView!.logo!.contentMode = .scaleAspectFit
let dismissButtonFrame = signUpView!.dismissButton!.frame
signUpView?.dismissButton!.frame = CGRect(x: 0, y: signUpView!.signUpButton!.frame.origin.y + signUpView!.signUpButton!.frame.height + 16.0, width: signUpView!.frame.width, height: dismissButtonFrame.height)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
This issue has been automatically marked as stale because it has not had recent activity. If you believe it should stay open, please let us know! As always, we encourage contributions, check out the Contributing Guide
Can you assign it to me? I want to help the project
Sure 🙂
Thanks @TomWFox its my personal account, so I will fork and PR from this account. I will have a look today night/morning after my job