BLImageCache *sharedImageCache = [BLImageCache sharedInstance];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:indexPath ,@"IndexPath", nil] ;
NSString *urlString;
urlString = [[mNewsArray objectAtIndex:indexPath.row] objectForKey:@"imgUrl"];
urlString =[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
UIImage *image=[sharedImageCache imageForURL:urlString];
if(image==nil)
{
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[sharedImageCache loadImageFromURL:[NSURL URLWithString:urlString] sender:self context:(NSDictionary*)dictionary];
}
else{
cell.imageView.image =image;
cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
The Application is crashing can Anyone tell me what I am doing wrong is there any Memory related Issue...
应用程序崩溃可以任何人告诉我我做错了是否有任何与内存相关的问题...
-(void)didLoadImage:(UIImage *)inImage contextInfo:(void *)inContext
{
if(inImage )
{
NSIndexPath *indexPath= [(id)inContext objectForKey:@"IndexPath"];
UITableViewCell *cell=[mTableView cellForRowAtIndexPath:indexPath];
inImage=[inImage resizeImagewithwidth:69 height:67];
cell.imageView.image=inImage;
}
}
1 个解决方案
#1
1
A backtrace would help. Where is it crashing?
回溯会有所帮助。它在哪里崩溃?
The problems I can see immediately is that you are escaping urlString
twice when loading remotely. Also, if urlString
happens to be nil, you'll get a crash when you try to convert it to create the NSURL
.
我可以立即看到的问题是你在远程加载时转发urlString两次。此外,如果urlString恰好为nil,当您尝试将其转换为创建NSURL时,您将遇到崩溃。
#1
1
A backtrace would help. Where is it crashing?
回溯会有所帮助。它在哪里崩溃?
The problems I can see immediately is that you are escaping urlString
twice when loading remotely. Also, if urlString
happens to be nil, you'll get a crash when you try to convert it to create the NSURL
.
我可以立即看到的问题是你在远程加载时转发urlString两次。此外,如果urlString恰好为nil,当您尝试将其转换为创建NSURL时,您将遇到崩溃。