【发布时间】:2015-06-11 05:00:01
【问题描述】:
我正在使用下面的代码注册用户,并使用用户名、密码和个人资料图片。当个人资料图片为JPG 时,它可以工作,但当格式为“PNG”时,不能。当我上传 png 图片时,图片是空白的。
我认为JPG 正在工作,因为我正在使用此功能UIImageJPEGRepresentation。
我应该为 PNG 使用什么?
背景:This thread
func createUserwithAllFields() {
let profileImageData = UIImageJPEGRepresentation(profileAvatar.image, 0.6)
//let profileImageData = UIImageJPEGRepresentation(profileImg, 0.6)
let profileImageFile = PFFile(data: profileImageData)
if tv_username.text != ""
&& tv_password.text != ""
{
var user = PFUser()
user.username = tv_username.text
user.password = tv_password.text
user["profileImage"] = profileImageFile
user.signUpInBackgroundWithBlock({ (success, error) -> Void in
if error == nil {
//if SignUp is successful
let installation = PFInstallation.currentInstallation()
installation["user"] = user
installation.saveInBackgroundWithBlock(nil)
//self.showChatOverview()
self.goToMainScreen()
} else {
}
})
}else{
}
}
【问题讨论】:
-
前几天我对它很好奇,我能够使用我发布的解决方案使其工作!
-
@Icaro sweet... 现在看起来很明显应该已经搜索过了。在我被解雇之前会试一试。
-
现在我们知道了,我花了很长时间才弄清楚第一次!
-
它对你有用吗?让我知道它是怎么回事,如果确实如此,请不要忘记将答案标记为已解决:) 谢谢
-
@Icaro 是的,它有效,谢谢。将您的答案标记为答案,它是第一个。
标签: ios xcode swift parse-platform uiimage