【发布时间】:2011-08-04 12:21:37
【问题描述】:
我的应用层次结构如下:
UINavigationController
|_____
UITableViewController (display products summary with thumbnail image)
|_____
UIViewController (display product details with image)
我正在使用以下类在 UITableViewController 和 UIViewController 中异步加载图像,因为从 Internet 获取图像时加载视图太慢
http://www.markj.net/iphone-asynchronous-table-image
我在 UITableViewController 中没有任何问题,问题是当单击单元格时它会在 UIViewController 中加载图像,如果我返回 UITableViewController 然后单击另一个单元格,UIViewController 会使用上一个图像打开,直到加载新图像
如何在 UIViewController 中重置 UIImageView 直到加载新图像?
这是加载详情视图的代码:
CGRect frame;
frame.size.width=240; frame.size.height=130;
frame.origin.x=0; frame.origin.y=0;
AsyncImageView* asyncImage = [[[AsyncImageView alloc] initWithFrame:frame] autorelease];
asyncImage.tag = 999;
NSURL *url = [NSURL URLWithString:@"http://i53.tinypic.com/5ezwc4.jpg"];
[asyncImage loadImageFromURL:url];
[detailsViewController.imgProduct addSubview:asyncImage];
请帮忙。
【问题讨论】:
-
贴出创建 detailsviewcontroller 的代码。您可能希望从中删除 asyncImage 或在点击 tableview 时重新创建控制器。
-
细节视图控制器是在IB中创建的,细节视图中asyncImage背后的原因是因为它从互联网读取图像打开细节视图太慢
标签: iphone objective-c uiviewcontroller uiimageview uitableview