Reputation: 3389
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?
Upvotes: 32
Views: 22901
Reputation: 2585
One more way we can
YourViewController *aYourViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"aYourViewControllerIdentifier"];
[self.navigationController pushViewController:aYourViewController animated:NO];
and add the @"aYourViewControllerIdentifier"
to view controller in your storyboard.
Upvotes: 6
Reputation: 18755
I am using this snippet to request authorization in viewDidLoad
:
[UIView setAnimationsEnabled:NO];
self.view.hidden = YES;
[self performSegueWithIdentifier:@"segue_auth" sender:self];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView setAnimationsEnabled:YES];
self.view.hidden = NO;
});
When authorized, back transition is animated as I want.
Upvotes: 9
Reputation: 2577
Duplicate your segue in Storyboard and give the second one a different ID.
You can then change the transition in the new version.
Upvotes: 51