我有一个函数,可以成功地将用户添加到我的Parse类中的user表,但我想添加一个头像到注册表单。
我可以从相机或照片库中选择图像并将其添加到我的imageView (profilePic)中,但当我尝试将其添加到signUpInBackground方法中时,它会使应用程序崩溃。
我完全是ios开发的新手,但熟悉其他编程语言,所以它不是完全陌生的,我只是不知道我在这里错过了什么,或者是不可能在注册时添加图像?
帮助!
let user = PFUser()
user.email = emailAddress.text
user.username = screenName.text
user.password = password.text
let image = self.profilePic.image
if image != nil {
let imagedata = UIImagePNGRepresentation(image!)!
let file = PFFile(name: "image.png", data: imagedata)
user["profilePic"] = file
}
user.signUpInBackground(block: { (success, error) in
if error != nil {
// error code
} else {
// user logged in successfully
}
}
}https://stackoverflow.com/questions/41449160
复制相似问题