2015-04-06 74 views
1

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

+0

您需要分配圖像的UIImageView像imageView.image =圖像。 – 2015-04-06 05:44:58

回答

0

我錯過了什麼?你把圖像放在imageView裏面嗎? (這就是爲什麼你會得到「未使用變量‘圖像’」)在您的情況

[imageView setImage:image]; 
+0

是是是是是是是是是是是是是是是是是是非常感謝@非常丹! – 2015-04-06 06:09:29

+0

謝謝@Kathiravan G – 2015-04-06 06:09:46

+0

3個月?????? – 2015-04-06 10:34:26