【问题标题】:How can get image from a path in to UITAbleViewCell?如何从 UITTableViewCell 的路径中获取图像?
【发布时间】:2010-04-23 10:48:29
【问题描述】:

我在 NSString *path1 中有以下路径,

/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/snook.jpg  

如何显示图像 snook.jpg。 我需要它在 UITableViewCell 中显示

cell.imageView.image   

如果 path1 有路径。我使用以下内容获取 path1 的最后一部分 snook.jpg。

NSURL *url = [NSURL URLWithString:path1];
NSString *imageString = [url path];

但是,url 显示为 nil。
我该怎么做 ? 谢谢。

【问题讨论】:

    标签: cocoa-touch iphone-sdk-3.0 uitableview uiimageview uiimage


    【解决方案1】:

    如果你有路径,那么你可以使用UIImage的“imageWithContentsOfFile:”方法:

    UIImage *img = [UIImage imageWithContentsOfFile:path];
    cell.imageView.image = img;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 2017-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多