ios개발/프로젝트

<ios프로젝트2>왜 이미지 로딩이 느린다.

studying develop 2020. 3. 20. 01:36

UIImage from url takes long time to load swift

음 

 

There will be issue because of Async call and ReUsability. Lets say your Image at IndexPath 1 is loading image but it is still taking time to download and meanwhile user scrolled down at some another index i.e. 15 and Internally the same cell of Index 1 is alloted to Index 15 and Image of cell 1 will be displayed in Cell 15 if you have not managed to handle previous calls for same instance of cell. Thats why its Better to use some caching library like SDWebImage(As @SeanLintern88 said) or AFNetworking's UIImageView Category

AlamoFire's UIImageView (For Swift)

Event if you wanted to do this, then better is to go with subclassing, it will help you to manage the Calls and Its termination.

In your case the Loading of Image might be because of Size of actual image that you are loading from server. CDN kind of service provide some easy to implement techniques to serve different size of images as per the request. So even If User has uploaded 1200x1200 sized image but on list screen you can fetch its 120x120 sized image, This helps is faster loading as well as it will save Physical Memories.