【问题标题】:IPhone- Rss sample code, modify to display images... PLease help!iPhone-Rss 示例代码,修改显示图像...请帮助!
【发布时间】:2011-03-03 14:53:42
【问题描述】:

我正在尝试制作显示 RSS 提要的应用程序,将文本和图像放入表格中,但我真的很挣扎!

我发现了一个非常好的[示例代码项目][1],我可以推荐它——但我很难让它在表格单元格中显示图像,而不仅仅是文本

如果有任何帮助,我会非常高兴!

谢谢

【问题讨论】:

    标签: xml parsing rss uiimageview nsxmlparser


    【解决方案1】:

    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 了解异步方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-12
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      • 2011-05-27
      • 1970-01-01
      相关资源
      最近更新 更多