I have been on an iOS 5 app in which I have an NSOperationQueue which works fine to get some data and create a UIViewController. However, at one point when every operation seems to be complete the app is unresponsive for quite a long time. Here’s how it goes:
- Get some data from DB
- Queue – For each item Init a custom UIViewController object.
- Hand each UIViewController object over to the MainViewController and display them.
Everything goes fine until the UIVC objects have to appear.
It goes past all the [[self view] addSubview:object.view]; and to the end of the function.
But then there is a huge lag, from 5 to 30 seconds before the NSLog statements inside the viewDidApear of the UIVC object show up…
So in code:
//MainViewController
-(void)displayNewView {
[[self view] addSubview:object.view];
NSLog(@"Done setup");
}
//-- Long unresponsiveness --//
//UIVC object
-(void)viewDidAppear:(BOOL)animated {
NSLog(@"Start appear");
[super viewDidAppear:animated];
}
What could be causing this? Am I missing something obvious?
Thanks for the help!
It seems like it was the complexity of each UIViewController that delayed the whole process.
To me they seem simple but I guess the iPhone doesn’t like creating 10 views at a time with several buttons, labels and images.
Simplifying the nib and making sure only what is used is allocated and initialized helped a lot.. but its still not perfectly fluid.