ios - 如何将我的网址图片放入轮播?
<p><p>我正在从 API 获取 URL 图片。我已将 UR 图像存储到字符串中。这是我的问题,我想将其显示到轮播中。我不知道该怎么做。以下是我尝试过的代码。</p>
<pre><code>for(int i=0;i<hotelIMAges.count;i++ )
{
NSDictionary *images=;
NSString *Images= ;
;
} //Here I have stored all the images into string..(https://***.jpg)
Carousel *carousel = [ initWithFrame:CGRectMake(0, 0,300, 262)];
;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您只需要<strong>异步处理</strong>,因为您当前的方法可以是同步请求并阻塞主线程直到下载完成。</p>
<p>考虑使用 <code>SDWebImage</code> 和它添加的 <code>UIImageView</code> 扩展来管理图像下载和显示。它还支持一个占位符图像,您可以提供该图像以指示下载正在进行中。</p>
<p>如果您使用任何第三方轮播检查异步方法来显示图像。我相信 <code>setImages</code>: 方法必须适用于本地存储在应用程序内的图像。如果您有任何疑问,请告诉我。</p>
<p>----已编辑----</p>
<p>您的 Carousel 正在使用同步方法来显示哪些阻塞了主线程。
您可以将 SDWebImage 用于您的目的。
为此,您需要下载 SDWebImage 以异步下载图像。您可以从下面的链接下载 SDWebImage。
您可以在 Carousel.h 类中将其用作 </p>
<pre><code>#import <SDWebImage/UIImageView+WebCache.h>
</code></pre>
<p>用下面的行修改你的设置方法。</p>
<pre><code>]
placeholderImage:];
</code></pre>
<p>详情请引用 SDwebpage 的 github 页面。如果您有任何疑问,请告诉我。
<a href="https://github.com/rs/SDWebImage#using-asynchronous-image-downloader-independently" rel="noreferrer noopener nofollow">https://github.com/rs/SDWebImage#using-asynchronous-image-downloader-independently</a> </p></p>
<p style="font-size: 20px;">关于ios - 如何将我的网址图片放入轮播?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/46859970/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/46859970/
</a>
</p>
页:
[1]