0
這裏是我傳遞到現場與圖像數據的代碼:解析加載圖像到UIImageView的iOS版
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
rowNo = indexPath.row;
PFUser *currentUser = [PFUser currentUser];
PFQuery *query = [PFQuery queryWithClassName:@"Photo"];
[query whereKey:@"username" equalTo:currentUser.username];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
_photo = [objects objectAtIndex:rowNo];
}];
[self performSegueWithIdentifier:@"showImageCloseup" sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
ImageCloseupViewController *destination = [segue destinationViewController];
destination.photoObject = _photo;
}
,這裏是用來加載圖像的代碼:
- (void)viewDidLoad
{
[super viewDidLoad];
PFFile *p = [_photoObject objectForKey:@"photo"];
[p getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if(!error){
UIImage *image = [UIImage imageWithData:data];
[_imageView setImage:image];
}
}];
由於某種原因,圖像未加載,爲什麼是這樣?我該如何解決它?
很酷,這個工程。我試圖接受你的答案,但它一直說「在一分鐘內接受」lol – shreyashirday
沒問題@ user3140562 - 我在底部做了一個更新,你應該看看,我認爲這將對你有長遠的幫助。祝好運與您的其餘項目! – Logan