iOS App takes too long to start

4k views Asked by At

I have an app with:

  • custom topbar and bottombar,
  • horizontal scrollview that contains 5 other vertical scrollviews
  • the scrollviews are filled with a grid of images (no collection view)
  • a view that comes in from left when you grab it (google play store style)

So i have some views in there and i don't make use of interface builder.

If i launch my app on my iPhone 4s (not in debugging mode) my app takes almost 10 seconds to load, so my splash screen is up for 10 seconds.

Why does my app take so long to load up?

I tested it and it takes only 1.3 seconds to load all the images from the memory.

Is my app taking 8.7 seconds only to load my layout?

I wrote all the layout by code, with no use of constraints, i assign the frame sizes and positions for all the views in viewWillappear() method of the viewController.

How can i make it faster to load at start? where am i doing wrong? can it be layout's loading fault?

Thank you

1

There are 1 answers

6
simodev On BEST ANSWER

Instruments revealed that my error was in assigning a font that i removed from the resources to a UILabel with the method

    button.titleLabel?.font = UIFont(descriptor: UIFontDescriptor(name: "MyFont", size: 21), size: 21)

this line was the problem, it was spending a lot of time looking for the font that was not there.

so i replaced that line with:

    UIFont.systemFontOfSize(21)

Hope this helps someone