我如何使用Parse创建一个注册页面,我也可以让用户在Swift中输入自己的个人资料图片。
答案 0 :(得分:1)
请检查以下代码,使用parse.com将照片字段添加到您的用户表中
var user = PFUser()
let imageData = UIImageJPEGRepresentation(userDetails.getPhoto(), 0.05)
let imageFile = PFFile(name:"image.jpg", data:imageData)
imageFile.save()
user.username = usrEntered
user.password = pwdEntered
user.email = emlEntered
user.setObject(imageFile, forKey: "photo")
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
self.messageLabel.text = "User Signed Up";
} else {
// Show the errorString somewhere and let the user try again.
}
}