ViewDeck / ViewDeck

An implementation of the sliding menu found in various iOS apps.
5.32k stars 964 forks source link

issue when swapping out centerController with closeLeftViewBouncing #23

Closed schemers closed 12 years ago

schemers commented 12 years ago

I'm using closeLeftViewBouncing with a completion block that reassigns centerController while the center is offscreen, and I noticed that the newly centerController view actually starts out 20 pixels higher it should, and animates down as it slides back to the left.

this is very noticeable under the simulator if you turn on slow animations.

Also noticeable on the phone itself, as it makes the animation feel jerky/jumpy.

I'm switching between 3-4 different UINavigationControllers.

Inferis commented 12 years ago

I haven't been able to reproduce this with the latest version. Could you give it a spin and let me know if it's fixed or that I should try harder? :)

schemers commented 12 years ago

yes, pulled I can still get it to happen.

As the center view is sliding back on screen it seems to start at screen 0,0, and as it is animating to the left, it also is animating downwards to 0,20.

It feels like it is happening the second time the same controller gets set to be the center. For example:

I have 3-4 top-level view controllers: A, B, C, D, and then the left view is a table view controller, and when you select a row, it swaps out the center.

So if I start with:

A [swipe to left, pick B as new center] B <--- slides in OK [swip to left, pick C] C <-- slides in OK [swipe to left, pick A] A <-- slides back in, but also animates down as it slides to the right

So maybe it has something to do with the previous state of a view controller's view when it gets removed and added back?

A/B/C are all UINavigtationControllers.

thanks.

schemers commented 12 years ago

A <-- slides back in, but also animates down as it slides to the right

I meant:

A <-- slides back in, but also animates down as it slides to the left

left/right gets confusing :) I'm using the leftController (initialized once to be table view controller), and centerController (which gets changed based on a row selected in leftController).

schemers commented 12 years ago

I'm also on master, and can try switching to develop if there are pending fixes on there.

Inferis commented 12 years ago

No, master and develop are the same at the moment.

Inferis commented 12 years ago

Can you try out the new TabbedExample in the develop branch? That example serves as a test vehicle for tabbar behavior but it should als have the scenario you describe (but it seems to work there). You can disable the tabbar by setting a define to no (see app delegate).

Since it's on develop, the code is experimental.

schemers commented 12 years ago

OK, tried to repro, couldn't.

I noticed you example scenario was very different then mine, in particular:

However, even after changing the example to match mine, I still couldn't repro the behavior.

Then I start doing some more digging to see what else could be different, and remembered our custom view controllers (inside of the UINavigationController) extend from a base controller that has some logic in its viewWillAppear to method to ensure that the status bar is correct, nav bar is hidden/shown as configured by the controller, etc.

So I commented out that logic in the base controller viewWillAppear, and the problem went away. Tracked it down to this line in particular:

[self.navigationController setNavigationBarHidden:mNavigationBarHidden animated:mNavigationBarAnimated];

So what is happening is the following

IIViewDeckController:

- (void)setCenterController:(UIViewController *)centerController {
    ...
    if (...) { naVController.navigationBarHidden = YES; }
    ...
    if (self.mustRelayAppearance) [self.centerController viewWillAppear:NO];
    ...
    if (...) navController.navigationBarHidden = NO;

so setCenterController seems to be setting the nav bar to hidden if it was not hidden, doing some stuff, calling my viewWillAppear, which knows it isn't supposed to be hidden so sets it back to hidden = NO, etc.

Turns out that the call:

[self.navigationController setNavigationBarHidden:mNavigationBarHidden animated:mNavigationBarAnimated];

was causing the funky behavior. The fix is simple enough, if I use the value for animated passed in (which you pass in as NO), the problem goes away. It was using mNavigationBarAnimated which is always set to YES.

For whatever reason, unhiding the nav bar animated was causing it to animate down as it slide to the left.

So the fix is definitely on my side, but I'm also curious as to why you have to hide/unhide the nav bar. Was it to work around some other issue?

thanks!