【发布时间】:2014-02-15 23:18:05
【问题描述】:
我有一个表格视图,其中填充了来自 RSS 提要的项目。选择一行时,标题、链接、描述和图像将传递到详细信息视图。这可行,但是在选择行和打开详细视图之间存在明显的延迟。我正在尝试找到一种方法来优化它,这样延迟就不那么明显了。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
GRSItemDetail *detail = [[GRSItemDetail alloc]initWithNibName:@"GRSItemDetail" bundle:nil];
RSSItem *entry = [[channel items]objectAtIndex:[indexPath row]];
NSURL *imageLink = [NSURL URLWithString:[entry bigImageURL]];
NSData *data = [NSData dataWithContentsOfURL:imageLink];
UIImage *image = [[UIImage alloc]initWithData:data];
detail.titleString = [entry title];
detail.descriptionString = [entry infoString];
detail.urlString = [entry link];
detail.itemImage = image;
[self.navigationController pushViewController:detail animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
【问题讨论】:
-
yes ,因为您在 didselect, 方法中从 url 加载数据。最好将 url 传递给 GRSItemDetail 并在 GRSItemDetail 的 viewdidload 中加载 url 内容。
标签: ios objective-c uitableview didselectrowatindexpath