我将如何使用 Parse 创建一个注册页面,我还可以让用户在 Swift 中输入自己的个人资料图片。
问问题
1618 次
1 回答
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.
}
}
于 2015-06-10T07:44:30.260 回答