I have an application which starts with a navigation controller. This navigation controller can open modal view controller:
- (void)openModalController:(id)sender
{
[self performSegueWithIdentifier:@"SegueIdentifier"];
}
But when the user opens an application using url scheme, I'd like to present the application with the modal controller opened. So I added some methods and tried:
// Controller
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated]; // animated == NO in initial loading
if (_shouldOpenModalController) {
[self openModalController:nil];
}
}
- (void)setShouldOpenModalController:(BOOL)flag
{
_shouldOpenModalController = flag;
}
// AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (launchOptions) {
UINavigationController *nc = (UINavigationController *)self.window.rootViewController;
MyViewController *c = (MyViewController *)[ns topViewController];
[c setShouldOpenModalController];
}
}
But here is a problem: the openModalController:
performs segue with transition animation I setup in storyboard. How can it be done with no animation? Is there another approach for this task?
UISegue
and overrideperform
. – Martol1ni Apr 24 '13 at 13:45- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier
but I don't think this is the best solution – voromax Apr 24 '13 at 13:49presentViewController:animated:completion:
. So one time I configure the controller inprepareForSegue:sender:
other time I should configure it in other place so I don't like it. Should I just drop using segues for this controller? – voromax Apr 24 '13 at 15:40prepareForSegue:
method either. I do use the storyboard to setup the interface though and instantiate them viainstatiateViewControllerWithIdentifier:
. – Tobi Apr 24 '13 at 16:01