【问题标题】:iOS - Loading an image from a web server in Objective CiOS - 在 Objective C 中从 Web 服务器加载图像
【发布时间】:2012-03-27 06:19:53
【问题描述】:

目前,我的目标是编写一个包含 UIImageView 的应用程序。加载或按下按钮后,来自网络服务器的图像将加载到视图中。

最简单的方法是什么?我假设使用这里描述的 API? https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

与此同时,我将继续尝试自己完成这项工作。任何建议都将不胜感激,尤其是如果您以前编写过这样的代码。

【问题讨论】:

    标签: objective-c ios image ipad


    【解决方案1】:

    是的,这可以通过 NSURLConnection 发出请求来完成。

    您可能有兴趣查看SDWebImage。这个库包括一个类别,它向UIImageView 添加了一个方法,它使得从远程 URL 异步加载图像变得如此简单:

    [self.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 2015-09-18
      • 1970-01-01
      • 2010-11-19
      相关资源
      最近更新 更多