0
我想從解析中加載圖像,如您在屏幕截圖中所看到的。 將圖像從解析加載到圖像視圖
我使用此代碼將標題圖像加載到我的imageview中。
PFQuery *query = [PFQuery queryWithClassName:@"AppOfTheDay"];
[query getObjectInBackgroundWithId:@"WDJpxs4PzH"
block:^(PFObject *retreive, NSError *error) {
{
NSString *text = [retreive objectForKey:@"description"];
if (error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
UIAlertView *error=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Connection Failed" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[error show];
}
else{
PFFile *imageFile = [retreive objectForKey:@"header"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
UIAlertView *error=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Something went wrong" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[error show];
}
else{
UIImage *image = [UIImage imageWithData:data];
_headerImage.image=image;
_appDescription.text=text;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}];
}
}
}];
我的問題是我怎樣才能同樣地加載我的其他三個圖像到圖像?
我我會試試這個。 – Machete
我第一次看到這個AsyncImageView * imageasy = [[AsyncImageView alloc] init];我有我的imageviews.outs不知道如何使用它們在這裏? – Machete
https://github.com/nicklockwood/AsyncImageView你可以下載AsyncImageView.h和.m類到你的項目中,這對減少圖像的加載是非常有用的,而不是使用uiimageview你可以這樣做,例如: - AsyncImageView * imageasy3 = [[AsyncImageView alloc] init];通俗地說,如果你創建uiimageview,你會像這樣分配UIImageView * imageasy3 = [[UIImageView alloc] init]; – Romance