【发布时间】:2011-03-03 14:53:42
【问题描述】:
我正在尝试制作显示 RSS 提要的应用程序,将文本和图像放入表格中,但我真的很挣扎!
我发现了一个非常好的[示例代码项目][1],我可以推荐它——但我很难让它在表格单元格中显示图像,而不仅仅是文本
如果有任何帮助,我会非常高兴!
谢谢
【问题讨论】:
标签: xml parsing rss uiimageview nsxmlparser
我正在尝试制作显示 RSS 提要的应用程序,将文本和图像放入表格中,但我真的很挣扎!
我发现了一个非常好的[示例代码项目][1],我可以推荐它——但我很难让它在表格单元格中显示图像,而不仅仅是文本
如果有任何帮助,我会非常高兴!
谢谢
【问题讨论】:
标签: xml parsing rss uiimageview nsxmlparser
将UIImageView 添加到表格的单元格中,并将其image 属性设置为图像。
你想在你的 cellForRowAtIndexPath: 方法中这样做:
-(UITableViewCell *)tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifer = @“MyIdentifier”;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
reuseIdentifier:MyIdentifier] autorelease];
UIImageView *imgView = [[UIImageView alloc] initWithFrame: CGRectMake(3,3,75,75)];
imgView.tag = 7;
}
[cell setText: (NSString*)[yourTextArray objectAtIndex: indexPath.row];
UIImageView *theImgView = (UIImageView*)[cell viewWithTag: 7];
theImgView.image = (UIImage*)[yourImageArray objectAtIndex: indexPath.row]
return cell;
}
查看this article 了解异步方法。
【讨论】: