我有一个应用程序,我正在从图像缓存中加载图像。`
if(![[ImageCache sharedImageCache] hasImageWithKey:imagepath])
{ cell.bannerview2.image = [UIImage imageNamed:@"no_imags.png"];
NSArray *myArray = [NSArray arrayWithObjects:cell.bannerview2,imagepath,@"no_imags.png",[NSNumber numberWithBool:NO],nil];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate performSelectorInBackground:@selector(updateImageViewInBackground:) withObject:myArray];
}
else
{
cell.bannerview2.image = [[ImageCache sharedImageCache] getImagefromCacheOrUrl:imagepath];
}
}
else
{
cell.bannerview2.image = [UIImage imageNamed:@"no_imags.png"];
}
这就是我执行图像缓存过程的方式。但问题是当图像大于所需帧时,图像方向正在改变。这是我在 appdelegate 中的图像更新代码
-(void)updateImageViewInBackground:(NSArray *)idsArray{
//NSLog(@"IN METHOD idsArray %@",idsArray);
NSString *iconurl = (NSString *)[idsArray objectAtIndex:1];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if([[ImageCache sharedImageCache] hasImageWithKey:iconurl]){
[self performSelectorOnMainThread:@selector(updateImageViewInForeground:) withObject:idsArray waitUntilDone:NO];
[pool release];
return;
}
if([iconurl length] > 0){
[[ImageCache sharedImageCache] saveImageToCacheOfUrl:iconurl];
}
[self performSelectorOnMainThread:@selector(updateImageViewInForeground:) withObject:idsArray waitUntilDone:NO];
[pool release];
}
-(void)updateImageViewInForeground:(NSArray *)idsArray{
UIImageView *weatherView = (UIImageView *)[idsArray objectAtIndex:0];
NSString *iconurl = (NSString *)[idsArray objectAtIndex:1];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
weatherView.image = [[ImageCache sharedImageCache] getImagefromCacheOrUrl:iconurl];
if(weatherView.image == nil){
NSString *defaultname = (NSString *)[idsArray objectAtIndex:2];
weatherView.image = [UIImage imageNamed: defaultname];
}
BOOL resizeImgView = [(NSNumber *)[idsArray objectAtIndex:3] boolValue];
if(resizeImgView){
//NSLog(@"resizeImgView %@ %@",iconurl,weatherView);
weatherView.frame = CGRectMake(weatherView.frame.origin.x, weatherView.frame.origin.y, weatherView.image.size.width, weatherView.image.size.height);
}
[pool release];
}
有谁能够帮我?