IPhone-Rss示例代码,修改为显示图像... PLease help!
问题描述:
我正在尝试使应用程序显示一个RSS源,并将文本和图像放入表格中,但我真的非常困惑!IPhone-Rss示例代码,修改为显示图像... PLease help!
我找到了一个真正的好[示例代码项目] [1],我真的可以recommend--但即时struggeling得到它在tablecells显示图像,而不是纯文本
的我将与reeeeally快乐任何帮助!
感谢
答
添加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一个异步方法。