在 Swift 中使用 Parse 创建具有个人资料图片的用户
Create a User with Profile Picture with Parse in Swift
我如何使用 Parse 创建一个注册页面,我还可以让用户在 Swift 中输入自己的个人资料图片。
请检查下面的代码,将照片字段添加到您的用户 table 和 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.
}
}
我如何使用 Parse 创建一个注册页面,我还可以让用户在 Swift 中输入自己的个人资料图片。
请检查下面的代码,将照片字段添加到您的用户 table 和 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.
}
}