0

I'm implementing a kind of cascading menu.

In my storyboard, I've got a UINavigationController which have a UIViewController as root view controller (let say it is a MyViewController). MyViewController has a storyboard ID : "Menu".
As this controller is a menu, it displays a tableView. When clicking on a cell, it triggers some code, especially :

UINavigationController *menuNavigator = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
MyViewController *newMenu = (MyViewController*)menuNavigator.topViewController;
//Some configurations of newMenu
[self.navigationController pushViewController:newMenu animated:YES];

Since here everything works fine.

In the submenu, the last cell is a "back" cell. When users touch it, it triggers code :

[self.navigationController popViewControllerAnimated:YES];

I return correctly on the previous menu, but without animations.

I've also tried :

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];

But I still have no animation.

On the storyboard, my navigation controller is set to not display the navigation bar. If I show it, and touch the "back" button that auto-appears, it's the same result : no animations.

What's wrong with my code?

Edit
I'm using Autolayout and ARC;

zbMax
  • 2,756
  • 3
  • 21
  • 42
  • 1
    Long shot: Did you probably miss to call `[super ...]` in any of your `viewDidLoad`, `viewWillDisappear`, ... methods? – plu Feb 12 '14 at 13:07
  • I am only overwriting `viewDidLoad` and `viewDidAppear:`. The second one was missing the `super` call, but even with this, it still not animating. – zbMax Feb 12 '14 at 13:15
  • make sure are you calling [super viewDidAppear] & [super viewDidLoad] ? – jailani Feb 12 '14 at 13:16
  • Sure. A weird behavior is that `viewDidAppear:` is not call on the root controller when "popping" the submenu with `popViewControllerAnimated:`. – zbMax Feb 12 '14 at 13:25
  • Do you ever call `[UIView +setAnimationsEnabled:]`? You can check whether `[UIView +areAnimationsEnabled]` returns `YES` or `NO`. – Aaron Brager Feb 12 '14 at 20:09
  • It returns me `YES` every time. – zbMax Feb 13 '14 at 07:43
  • Did you ever figure this out? I'm having the same issue as well. – Brian F Leighty Jul 09 '15 at 20:27

1 Answers1

0

Edit: you've got something funny going on. This line of code looks wrong:

UINavigationController *menuNavigator = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];

It looks like you try to get the navigation controller by instantiating a view controller. I don't see why you need to get the navigator like that. You can simply get the navigation controller with self.navigationController.

I do something similar, and my code looks like the following.

In the didSelectRowAtIndexPath: method, I don't instantiate via the storyboard object but instead do:

    DVSecondTableViewController *vc = [[DVSecondTableViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];

To go back, I just use the Back button that the navigation controller provides, so I can't help you there.

Bart van Kuik
  • 4,704
  • 1
  • 33
  • 57
  • I've been creating my view programmatically without the storyboard. (BTW, I don't understand why you call `initWithNibName:bundle:` with nil arguments instead of `init`...) My problem still the same. Can autolayout constraints be in fault? – zbMax Feb 12 '14 at 14:07