Iphone 将图像从解析加载到图像视图
我想从parse加载图像,正如您在屏幕截图中看到的那样 我正在使用此代码将标题图像加载到imageview中Iphone 将图像从解析加载到图像视图,iphone,ios,parsing,ios4,Iphone,Ios,Parsing,Ios4,我想从parse加载图像,正如您在屏幕截图中看到的那样 我正在使用此代码将标题图像加载到imageview中 PFQuery *query = [PFQuery queryWithClassName:@"AppOfTheDay"]; [query getObjectInBackgroundWithId:@"WDJpxs4PzH" block:^(PFObject *retreive, NSError *error) { { NSSt
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];
}
}];
}
}
}];
我的问题是如何将其他三个图像加载到ImageView中?实现延迟加载图像。 例如,NSURL*url=[NSURL URLWithString:urlString]
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
if ( queue == nil )
{
queue = [[NSOperationQueue alloc] init];
}
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse * resp, NSData *data, NSError *error)
{
dispatch_async(dispatch_get_main_queue(),^
{
if ( error == nil && data )
{
UIImage *urlImage = [[UIImage alloc] initWithData:data];
thumbnail.image = urlImage;
}
});
}];
我希望它将帮助你很多,它将以最佳的装载速度解决你的问题 //你的班级
AsyncImageView *imageasy,*imageasy1, *imageasy2,imageasy3;
你的班级
PFQuery *query = [PFQuery queryWithClassName:@"AppOfTheDay"];
[query getObjectInBackgroundWithId:@"WDJpxs4PzH"
block:^(PFObject *comment, NSError *error) {
if (!error) {
PFFile *post = [comment objectForKey:@"PhotoName"];
PFFile *post2 = [comment objectForKey:@"logo"];
PFFile *post3 = [comment objectForKey:@"similar1"];
PFFile *post4 = [comment objectForKey:@"similar2"];
imageasy=[[AsyncImageView alloc] init];
imageasy1=[[AsyncImageView alloc] init];
imageasy2=[[AsyncImageView alloc] init];
imageasy3=[[AsyncImageView alloc] init];
[imageasy setImageURL:[NSURL URLWithString:[post url]]];
[imageasy1 setImageURL:[NSURL URLWithString:[post2 url]]];
[imageasy2 setImageURL:[NSURL URLWithString:[post3 url]]];
[imageasy3 setImageURL:[NSURL URLWithString:[post4 url]]];
}];
我要试试这个,这是我第一次看到AsyncImageView*imageasy=[[AsyncImageView alloc]init];我的ImageView有插座。我不知道如何在这里使用它们?您可以将AsyncImageView.h和.m类下载到您的项目中,这对于减少映像的加载非常有用,您可以这样代替uiimageview,例如:-AsyncImageView*imageasy3=[[AsyncImageView alloc]init];一般来说,如果您创建uiimageview,您将像这样分配uiimageview*imageasy3=[[uiimageview alloc]init];实际上,我的应用程序主屏幕上有四个ImageView。这将如何将所需的图像加载到我的ImageView?