andreamazz/SlideOutNavigation

Jumping on transition

donaciano opened this issue · 5 comments

I've been loading my slideOutNavigation class after the user passes a login prompt. I replace the rootviewcontroller inside a UIView transitionWithView animation block.

Works well except the navigation bar at the top drops 20 points immediately after the transition completes, only on iOS 7.0.

From my digging around it seems right now that most likely I'm facing the same issue described here: http://stackoverflow.com/questions/14795645/uinavigationbar-jumps-20pixels-during-transitionfromviewcontroller

I have attempted the suggested resolution (it didn't work) but maybe I did it wrong. I can't get a handle on how SlideOutNav is using the navigation bar.

Specifically I don't understand the following: (AMSlideOutNavigationController.h)
@Property (nonatomic, assign) Class navigationBarClass;

and also in the corresponding .m file
self.contentController = [[self.navigationControllerClass alloc] initWithNavigationBarClass:self.navigationBarClass toolbarClass:self.navigationToolbarClass];

It looks to me like maybe AMSlideOutNavigationController is subclassing uinavigationbar in an indirect way. The superclass is UIViewController, and no UINavigationBarDelegate protocol is being declared, so perhaps this is a trick to get around single-inheritance?

I tried adding - (BOOL)wantsFullScreenLayout but there was no change.

Any suggestions?

Hi @donaciano, the line of code

@property (nonatomic, assign) Class navigationBarClass;

is there just to allow a developer to use his own custom navigation bar. The default value is the standard UINavigationBar.
So I would rule out that part.

To be honest I didn't fully understand what issue you are referring to. What's the navbar behavior that you are expecting, and which one are you obtaining right now?

Okay, while slowing down the animation to get screen shots I can better tell what's going on.

Transitioning from another rootviewcontroller to a new slideoutnavigationcontroller
ios simulator screen shot nov 9 2013 8 35 12 am

ios simulator screen shot nov 9 2013 8 44 26 am

Immediately after transition completes, navigationbar changes size.
ios simulator screen shot nov 9 2013 8 35 14 am

You can see where the menu icon and Share text are that they'd be very close to the status bar text, also the gap before the text below is about 40 points, so the view below the navigationbar is at the correct position and does not move when the animation completes, only the navigation bar changes. This only happens on iOS 7.0.

Ok, I see.
You can try to subclass a UINavigationController and add the code suggested in that Stackoverflow thread. Then you can pass your custom UINavigationController's class to the slideout controller, via its property, like this:

self.slideoutController = ..... // init here
self.slideoutController.navigationControllerClass = [YourCustomNavController class];

This way your custom UINavigationController (that implements the fullscreen delegate) will be used instead of the standard one.
Let me know if that works.

Got it! The previously posted method did not work. They were actually fighting with iOS 6.0 in that particular thread, making it completely irrelevant to this one.

On the other hand...

http://stackoverflow.com/questions/19136899/navigation-bar-has-wrong-position-when-modal-a-view-controller-with-flip-horizon

The trick is to add:
[self.navigationController.navigationBar.layer removeAllAnimations];

To the view being presented in it's viewWillAppear.

My suspicion is, that as step 4 on this page (http://blog.jaredsinclair.com/post/61507315630/wrestling-with-status-bars-and-navigation-bars-on-ios-7) explains UINavigationController determines it's size on iOS 7.0 based on whether or not it's touching the top of the UIWindow.

Whenever it's doing this calculation, it's somehow conflicting with the animation. There's other similar problems animating the transition such as (http://stackoverflow.com/questions/19317988/ios7-custom-transitions-with-uinavigationcontroller?rq=1) and their fix was to place the view containing it below the screen so it could correctly calculate it's size and then to move it into view.

If people start running into this issue more as they transition their apps over to iOS 7.0 there might be a trick you could put in the slideoutnav to avoid it, but for now this workaround should be sufficient for most cases.

Good to know, thanks for your feedback.