我在这里看过很多贴子,社区有惊人的答案。不幸的是,没有人能够帮助或指导我需要帮助。我试着去“取”的形象,“当前用户”上传到同一个“的UIImageView”从parse.com取得1张图片
下面解析是我如何上传照片
myaccount.h的例子
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)UploadPhoto:(id)sender;
- (IBAction)selectPhoto:(id)sender;
myaccount.m
- (IBAction)UploadPhoto:(UIButton *)sender {
PFObject *User = [PFUser currentUser];
NSData *imageData = UIImageJPEGRepresentation(_imageView.image, 0.8);
NSString *filename = [NSString stringWithFormat:@"%@.png", _username.text];
PFFile *imageFile = [PFFile fileWithName:filename data:imageData];
[User setObject:imageFile forKey:@"ProfilePicture"];
// Show progress
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Uploading";
[hud show:YES];
// Upload Profile Picture to Parse
[User saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
[hud hide:YES];
if (!error) {
// Show success message
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Upload Complete" message:@"Successfully uploaded profile picture" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
// Dismiss the controller
//[self dismissViewControllerAnimated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Upload Failure" message:[error localizedDescription] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}];
}
老实说,我不知道在哪里何去何从!该照片完全上传到parse.com上的类...但我无法让它显示每次应用程序viewdidloads这个控制器。
我试图
- (void)viewDidLoad {
[super viewDidLoad];
PFFile * myPFFile = [[PFUser currentUser] objectForKey:@"ProfilePicture"];
[myPFFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
UIImage *image = [UIImage imageWithData:data];
// image can now be set on a UIImageView
}
}];
,但我得到有关的UIImage “图像” 未使用可变*图像= [UIImage的imageWithData:数据];
我做错了什么。有人请帮我解决我错过的任何代码。我已经在这里3个月了,它阻止我前进.... PPPPLLZZZ帮助
您需要分配图像的UIImageView像imageView.image =图像。 – 2015-04-06 05:44:58