1

I've got an app that is a list of itens in a table view and displays a detail view controller to every item on the table view. It also implements MMDrawerController (root view controller) as a side menu with storyboard. I'm deep linking my app and using application open URL source application annotation method from App Delegate to handle it. So, I want to push a detail view controller from this method using MMDrawerController and I'm having some trouble. Have a look in some code:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

       UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
      DetalheRestauranteViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"detalheRest"];

      MMDrawerController* drawerController = (MMDrawerController *)self.window.rootViewController;
      // If I use this nothing happens        
      [drawerController.centerViewController.navigationController pushViewController:vc animated:YES];

      // If I use this nothing happens      
      [((MMDrawerController *)self.window.rootViewController).centerViewController.navigationController pushViewController:vc animated:YES];

     // If I use this I got the unrecognized selector error       
     [(UINavigationController*)self.window.rootViewController pushViewController:vc animated:NO];

    return YES;
}

Can someone help me with this?

Rafael Nascimento
  • 309
  • 1
  • 4
  • 14

2 Answers2

0

I have found that with deep linking and the new iOS9 menu shortcuts that a small delay is often needed to display or manipulate UI Components.

I would try moving all of your UI/MMDrawer code to its own method. Then when openURL is called in your app delegate, call your new method on a delay.

So in ObjC it would look something like this:

 [self performSelector:@selector(showDetailView) withObject:nil afterDelay:0.3];
Richmond Watkins
  • 1,342
  • 9
  • 17
0

do you solve this problem?

I tried many times. Finally I found it works fine for me today:

[((UINavigationController *)((MMDrawerController *)self.window.rootViewController).centerViewController)  pushViewController:viewController animated:YES];

or

MMDrawerController *mvc = (MMDrawerController *)self.window.rootViewController;
UINavigationController *nvc = (UINavigationController *)mvc.centerViewController;
[nvc pushViewController:vc animated:YES];

These two kinds of writing are the same.

Here vc is one DetalheRestauranteViewController instance.

lecover
  • 62
  • 4