Reputation: 1213
I have a UINavigationController and on the UINavigationBar i have a Button. When i press this Button, a new UINavigationController is presented modally as a UIModalPresentationFormSheet. This works.
But i recognized that the presentation of the FormSheet is quite time consuming. I put two logs in the action method ("start" and "finish", see code below), one in the first and one in the last line. The log time tells me, that it takes about 1,5 to 2 seconds to run this code.
Thats the Action method called from the UINavigationItem:
- (IBAction)addBtnPressed:(id)sender{
NSLog(@"start");
FooViewController *fooContr = [[FooViewController alloc] init];
fooContr.delegate = self;
UINavigationController *navContr = [[UINavigationController alloc] initWithRootViewController:fooContr];
[fooContr release];
navContr.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentModalViewController:navContr animated:YES];
[navContr release];
NSLog(@"finish");
}
It seems that the line
[self.navigationController presentModalViewController:navContr animated:YES];
takes 90% of the time.
Does anybody know whats going on here and how to optimize that?
Upvotes: 2
Views: 475
Reputation: 8163
Preload the UINavigationController
with the FooViewController
so when you present it it is already in memory.
What it is probably taking so much time is the loading of the FooViewController
instance's view.
You can make it load by doing something to it. Like
UIView *view = fooContr.view;
You should do this before the button that presents the modal view controller gets clicked. Otherwise it will probably have the same effect.
Upvotes: 2
Reputation: 5393
Minimise what code you have in your init in viewControllers, move code to viewDidLoad where possible or even viewDidAppear as appropriate (code meant to be run just once should be in viewDidload).
Upvotes: 0
Reputation: 25144
The performance issue must be because your navContrManAufn
takes time to create itself. What does it perform upon init ?
Upvotes: 0