Nic Hubbard
Nic Hubbard

Reputation: 42139

iOS: Refactor Large XIB into a few smaller XIB files for speed

When watching some of the WWDC2011 videos it was mentioned that large nib files can make your app take some time to load. This isn't necessarily the case with my app, but I feel like my nib is fairly large. The suggestion on the video was to make that large nib into a few smaller ones for quick load time.

Maybe I am missing something, but how would I split up a large nib into smaller ones? My UIViewController will only load one nib when it inits. Is there another way to do it will multiple files?

Upvotes: 2

Views: 431

Answers (1)

Jonah
Jonah

Reputation: 17958

As you noted you can init a UIViewController with a specified nib to load its view property and that's only a single file. However you need not pack all of your view property's subviews into the same nib file. If you have some subviews which are only visible some of the time consider splitting them out into their own nib files and loading them on demand using UINib. If you have a set of UITableViewCell subclasses or tiles for a UIScrollView's content you probably want to be able to load only the view instances you actually need and not a massive nib containing extraneous views (e.g. loading all of your table cells when you only use one of them).

Upvotes: 1

Related Questions