Including many images in an iPhone app without slowing down xcode

I have an application in which I query the database and upload a large number of small images. I am currently adding images as a resource to an iPhone project in xcode (by dragging and dropping it into the resources folder in the corresponding group). However, I am trying to add a function that adds an additional 8000 images to the project.

After adding these images, I notice that the interface builder is getting very slow to load image previews. This leads to the fact that IB is extremely unresponsive, using a lot of CPU. If I turn off synchronization with xcode, it does not load the image preview at all.

Is there a way to enable and map these images in an efficient way that will not slow down the user interface. I would like my user interface not to slow down depending on the number of images in my project.

+4
source share
2 answers

I developed an application containing much more images without any one problem (except for the build / package stage, which takes more than 1 GB of data).

The key is to add the folder containing the images as a "link to the folder", and not as a group and individual items. When accessing images, you need to do even more magic than [UIImage imageNamed:@"..."] .

You get to the image path using

 [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"yourdirectory"] 

and adding file names (and / or reading directory contents, of course)

ps. this assumes that you are not actually using images in Interface Builder.

oh and one more tip: during development, as soon as you install the application for the first time, you can remove images from your application in xcode. Until you uninstall the application from your device, the images will still be on the device accessible to your code, but creation and installation will be faster.

+10
source

This is a HUGE amount of images to add. Naturally, Xcode will take some time to process all of them, first in the first build.

If you do not clear your builds or remove your application from Simulator, then Xcode should process them faster if they do not change.

As for slowing down the user interface, try not to load all the images in 1 instance; for example, having a table with 8000 images, theres just no way to slow it down, even in a simulator.

+1
source

Source: https://habr.com/ru/post/1339293/


All Articles