I am looking to program a UILabel to give confirmation if signup was successful or unsuccessful. I am lost on how to go about creating it. I have a label placed in the SignUpViewController. I am lost on where to go about setting up the code to give the feedback though. Please let me know how to go about doing this. Thank You in advanced.
import UIKit
class signUpViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate {
@IBOutlet var usernameTextfield: UITextField!
@IBOutlet var emailTextfield: UITextField!
@IBOutlet var passwordTextfield: UITextField!
@IBOutlet var compasswordTextfield: UITextField!
@IBOutlet var birthdateTextfield: UITextField!
@IBOutlet var combirthdateTextfield: UITextField!
@IBOutlet var confirmationLable: UILabel!
@IBAction func signupButton(sender: AnyObject) {
var pahser:PFUser = PFUser()
pahser.username = usernameTextfield.text
pahser.email = emailTextfield.text
pahser.password = passwordTextfield.text
pahser.signUpInBackgroundWithBlock{
(success:Bool!, error:NSError!)->Void in
if error == nil {
println("Signup Successfull")
var imagePicker:UIImagePickerController = UIImagePickerController()
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)
}else{
let errorString = error.localizedDescription
println(errorString)
}
}
}
func imagePickerController(picker: UIImagePickerController!, didFinishPickingMediaWithInfo info: NSDictionary!) {
let pickedImage:UIImage = info.objectForKey(UIImagePickerControllerOriginalImage) as UIImage
let scaledImage = self.scaleImageWith(pickedImage, and: CGSizeMake(100, 100))
let imageData = UIImagePNGRepresentation(scaledImage)
let imageFile:PFFile = PFFile(data: imageData)
PFUser.currentUser().setObject(imageFile, forKey: "profileImage")
PFUser.currentUser().saveInBackground()
picker.dismissViewControllerAnimated(true, completion: nil)
}
func scaleImageWith(newImage:UIImage, and newSize:CGSize)->UIImage{
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
newImage.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height))
UIGraphicsEndImageContext()
return newImage
}
override func viewDidLoad() {
super.viewDidLoad()
self.passwordTextfield.delegate = self;
self.usernameTextfield.delegate = self;
self.emailTextfield.delegate = self;
self.compasswordTextfield.delegate = self;
self.birthdateTextfield.delegate = self;
self.combirthdateTextfield.delegate = self
}
// Do any additional setup after loading the view.
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func textFieldShouldReturn(textField: UITextField!) -> Bool {
self.view.endEditing(true);
return false;
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}