我想用一个查询来绘制我的用户在 UIImageView 中的个人资料图片......这段代码给了我图片,但只有昵称......你能帮我理解错误在哪里吗?
谢谢!
-(void)viewDidAppear:(BOOL)animated {
//Prepare the query to get the profile image
//1
PFQuery *query = [PFQuery queryWithClassName:@"User"];
PFQuery* queryPhoto = [PFQuery queryWithClassName:@"Foto_Profilo"];
//2
PFUser* currentUser = [PFUser currentUser];
if (currentUser) {
[query whereKey:@"user" equalTo:currentUser];
[queryPhoto whereKey:@"Immagine" equalTo:currentUser];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// Verify if there are no errors
if (!error) {
// Retrieve Usename
self.profileViewUsernameLabel.text = [NSString stringWithFormat:@"%@",[[PFUser currentUser]valueForKey:@"username"]] ;
// Retrieve Photo
PFObject* profilePhotoObject = [PFObject objectWithClassName:@"Foto_Profilo"];
PFFile* currentUserPhoto = (PFFile *)[profilePhotoObject objectForKey:@"Immagine"];
UIImageView* currentUserImage = [[UIImageView alloc]initWithImage:[UIImage imageWithData:currentUserPhoto.getData]];
[self.showfoto addSubview:currentUserImage];
} else {
NSString *errorString = [[error userInfo] objectForKey:@"error"];
UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[errorAlertView show];
}
} ];
}
}