2

I'm making an app that allows you to quickly change your brightness, but that was rejected for not having enough features, so I'm merging it with my battery app. If I only load the brightness stuff and have a button that says "load rest of app", which when pressed, loads the rest of the interface as below:

(IBOutlet previously made)

batterymeter = [[UIImageView alloc] initWithFrame:CGRectMake(150,300,250,50)];
batterymeter.image = [UIImage imageNamed:@"batteryfill.png"];

will that slow down the loading time? If not, how could I go about loading half an interface?

justin
  • 104,054
  • 14
  • 179
  • 226
Greg
  • 1,296
  • 2
  • 11
  • 26

1 Answers1

1

Constructing your UIs programmatically can reduce load times. There's less to read from disk, less to parse, and you can write an implementation which loads faster.

NIBs may also be cached to close that gap.

For many applications, it wont matter -- just use what fits the design best (that may be NIBs if that is what you are most familiar with). For complicated or performance critical apps, programmatic creation is often the way to go. For really large apps, there are a number of other considerations.

You can just use separate NIBs or programmatic implementations to do partial loads. However, load times should not be noticeably long in either case. If it is, then see what the profiler shows you.

justin
  • 104,054
  • 14
  • 179
  • 226
  • I'm sorry if I didn't make this clear, but I meant to ask whether it would be slower than having just the brightness stuff. As in, can I add the extra stuff without losing the fast loading time? – Greg Feb 05 '12 at 20:35
  • @Greg there's not enough context. yes, it will take longer. whether that is noticeably long depends on what exactly you are doing. loading a nib, `UIImageView`, and loading a small image doesn't take noticeably long. if it's a very large image -- that may be different. my recommendation: try it, if it's noticeably slow, determine why and/or ask for help in a more specific domain. too much speculation otherwise. – justin Feb 05 '12 at 21:10