xcode 如何将图像从 url 加载到 UITableViewCell?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13303008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:02:53  来源:igfitidea点击:

How to load a image from url to UITableViewCell?

iphonexcodeuiimageviewstoryboard

提问by IronManGill

I am new to iOS developer, using StoryboardI get Imagefrom the URL and load an image to the UITableviewcellwhen scroll the tableviewthe table will scroll very slowly and struck to scroll.

我是 iOS 开发人员的新手,使用StoryboardImage从 URL获取并在滚动时将图像加载到UITableviewcelltableview表格将非常缓慢地滚动并滚动。

回答by jithinroy

You should use lazy loading of image in your cells. The slowness or stuck is happening because you are fetching the image (..ie a network activity) in your main thread or the UI thread.

您应该在单元格中使用延迟加载图像。缓慢或卡住的发生是因为您正在主线程或 UI 线程中获取图像(..即网络活动)。

You can get a lot of tutorial in net for loading images async. Here is a tutorial from Apple : link

你可以在网络上获得很多关于异步加载图像的教程。这是来自 Apple 的教程:链接

回答by Paras Joshi

see the answer from this question for AsynchImage.. iphone-download-asynchronous

请参阅此问题的答案 AsynchImage .. iphone-download-asynchronous

also use AsynchImage for download image and set in UITableViewCell as a image

也使用 AsynchImage 下载图像并在 UITableViewCell 中设置为图像

asynchronous-loading-of-images-in-a-uitableview

异步加载图像在一个uitableview