【发布时间】:2011-07-05 15:55:20
【问题描述】:
我正在使用以下代码在 UIWebview 中加载图像。对于每个图像(在滚动我的滚动视图时),都会调用一个函数来加载图像。问题是当我连续滚动最多 30 张图像时,应用程序崩溃了。可能是什么原因?我的图像是 1300 x 1200 像素。请帮我找到解决方案。
- (void) loadCatalogImage
{
@try{
// if(imgView.image != nil)
// return;
// [global_imgProgress startAnimating];
//NSLog(@"image loading at = %@, %d", baseURL, 2 + pageNo);
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
//NSArray *array = [global_ContentString componentsSeparatedByString:@"@@#"];
NSArray *array1 = [catalogURL componentsSeparatedByString:@"&"];
//NSLog(@"baseURL = %@",baseURL);
NSLog(@"loading catalog image(method: loadCatalogImage).......%@%@",baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:0]);
zoomedImageURL = [NSString stringWithFormat:@"%@%@", baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:1]];
// NSLog(@"Catalog ZOOM URL = %@", zoomedImageURL);//[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"]);//[[[array objectAtIndex:[[global_CatalogRef objectAtIndex:pageNo] intValue]] componentsSeparatedByString:@"##"] objectAtIndex:3]);
[zoomedImageURL retain];
NSLog(@"aaaaaaa = %@",zoomedImageURL);
[webView loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:
[NSString stringWithFormat:@"%@%@",baseURL, [[[array1 objectAtIndex:0] componentsSeparatedByString:@"##"] objectAtIndex:1]
]
]]
];
}
}
【问题讨论】:
-
您在控制台上获得了哪些堆栈跟踪或崩溃信息?您的项目是否产生任何警告?
-
仅供参考:您没有释放正在创建的池。
-
@Madhumitha:你的解决方案是什么?
标签: iphone ipad memory-management uiscrollview