我在這裏看過很多貼子,社區有驚人的答案。不幸的是,沒有人能夠幫助或指導我需要幫助。我試着去「取」的形象,「當前用戶」上傳到同一個「的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