用户注册然后他/她可以拍照将其用作Userimage(图像具有名称图像并保存在imageToUpload中)然后我将其上传到Test类。我已经放置了一个进度条,向用户显示上传图片的进度(进度条的名称为progressBar)
PFUser *currentUser = [PFUser currentUser];
NSData *imageToUpload = UIImageJPEGRepresentation(_image, 0.8f);
PFFile *photoFile = [PFFile fileWithData:imageToUpload];
PFObject *User = [PFObject objectWithClassName:@"Test"];
User[@"username"] = currentUser.username;
User[@"UserImage"] = photoFile;
[User saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
_useThisPicture.enabled = NO;
} else {
_useThisPicture.enabled = YES;
} progressBlock:^(int percentDone) {
[_progressBar setProgress: (float)percentDone/100.0f];
};
}];
一切正常,我现在唯一困住的就是progressBlock。我的目标是更改进度的值,以便显示上传到解析图像的当前进度。