Best way of loading images from application bundle

前端 未结 4 777
既然无缘
既然无缘 2021-02-07 09:20

What is the best way of loading images from the application main bundle. I am using

[UIImage imageNamed: \"image.png\"];

But I have heard that

4条回答
  •  不知归路
    2021-02-07 09:57

    If you want to try loading the images without caching, you can use:

    [[UIImage alloc] initWithContentsOfFile:@"image.png"]; 
    

    This could be slightly faster loading the image for the first time, since it doesn't have to cache it first. If you only need to use these images once, it probably makes sense to try it this way. The other benefit of doing it this way is that you won't have an image cache using up memory for longer than necessary.

提交回复
热议问题