拍摄图片
我正在使用此问题中的代码拍摄图片: Scaling UIImage with a UIIImagePicker's CGAffineTransform and Saving to Parse SDK
将UIImage转换为NSData&保存
_imageData = UIImageJPEGRepresentation(_image, .1);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:_imageData];
newMessage[@"image"] = imageFile;
问题:
当我重新下载数据时,UIImage会出现挤压。当我查看数据库中的图像时,高度和宽度似乎相反。不知道为什么会这样......
答案 0 :(得分:0)
NSData *imageData = UIImageJPEGRepresentation(yourImage, 1.0);
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];
PFObject *userPhoto = [PFObject objectWithClassName:@"Photo"];
[userPhoto setObject:imageFile forKey:@"image"];
// Set the access control list to current user for security purposes
userPhoto.ACL = [PFACL ACLWithUser:[PFUser currentUser]];
[userPhoto setObject:user forKey:@"user"];
[userPhoto saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"sucess");
}
else{
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
[[ConnectionManager sharedManager] removeload];
}];