meese
meese

Reputation: 381

Loading xib file with date pickers slow

I have a xib file with 2 date pickers in it a few labels and a segment control. I was loading the xib's associated view controller into a popover and it was extremely slow loading only on the first time you open it(~5 seconds to load). So I put a reference to the view of the date picker controller outside of the open popover method and in its parents init method and sure enough loading the parent view controller is slow on load now and the open popover method goes fast. So I came to the conclusion it is the xib file connecting outlets/loading that is slow.

Removing everything from the date picker controller's viewDidLoad and init methods did not help.

Removing 1 date picker improved the speed considerably and adding more date pickers didn't appear to effect the speed at all.

Happens on both ios 5.1 and 6.0.

I can get around it by just dispatching another thread to load it on start but does anyway have a clue why this would be slow? I have seen other apps use multiple date pickers in one view with no trouble.

Upvotes: 2

Views: 965

Answers (1)

meese
meese

Reputation: 381

Solution was just to load it when the app starts up and keep reusing the same controller it will cause a small start up delay but its better than unresponsive controls, so in your app delegate call something like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  //only use this one controller, allocing another one will be just as slow
  self.datecontrollerwith2pickers = [[datecontrollerwith2pickers alloc] init];
  //forces xib to load
  self.datecontrollerwith2pickers.view;
}

The slow loading is most definitely a bug in Apple's code somewhere.

Upvotes: 3

Related Questions