iOS UINavigationController push/pop cross horizontal cover animation - ios

The pushed controller cross over current controller.
Results are as follows:
image 0
Actually, I have hook into this app, it use a subclass named MMUINavigationController,
and I am sure current action is "pushViewController:animated:", it's the interface I hooked.
Tweak.xm:
image 1
alertView:
image 2
how to make it ?
additional,standar animation:
image 3
navigation bar of pushed controller
image 4

Here's one solution:
hide the navigation bar of the navigation controller
add a navigation bar to the root view controller of the navigation controller
restore the swipe to back gesture to the navigation controller
For the last point you can add a pan gesture recognizer (suggested) or simply set the interactivePopGestureRecognizer's delegate of the navigation controller to nil:
self.navigationController?.interactivePopGestureRecognizer?.delegate = nil;
but please refer to this discussion for its implications: No Swipe Back when hiding Navigation Bar in UINavigationController
EDIT:
Working solution which fulfills the requirements: just setting the navigationBarHidden in the viewWillAppear does the magic.
I've setup a sample demo here: https://github.com/ldantona/NavigationBarExample
EDIT 2:
Just found this library, could it be of any help?
https://github.com/MoZhouqi/KMNavigationBarTransition
The library can capture the background style of the navigation bar in
the disappearing view controller when pushing, and when you pop back
to the view controller, the navigation bar will restore the previous
style, so you don't need to consider the background style after
popping. And you also don't need to consider it after pushing, because
it is the view controller to be pushed that needs to be considered.
Hope it helps

Related

present modal view hides the navigation bar in navigation stack

I have spent hours on this wired problem.
The scenario is I have push a new chatting view controller to the root navigation controller.
Then I customized the navigation bar item in the viewdidload method.
Everything works fine.
Then I present a image picker view which enables the image upload function.
And dismiss that picker view, which was presented as modal view.
After the picker view dismissed, the customized left navigation bar button disappeared.
The navigation bar appearance is the same as the root navigation bar but not the customized appearance is the current view controller.
Because the some pieces of the work includes the third party SDK, so I am not able to directly change the UIPickerView in order to detect the dismiss event and change the navigation bar appearance.
Can anyone helps? Thank you so much.
You should removed customised the navigation bar item on viewWillDisappear and add this viewWillAppear instead of viewDidLoad

Strange UINavigationItem behavior after using custom navigation transitioning animations

I am doing a custom UINavigationController pop transition animation.
But having a strange bug, I've made a sample project to demonstrate the issue (Taken from https://github.com/objcio/issue5-view-controller-transitions)
An navigation-based app, 2 view controllers.
The first viewController has 2 bar button items on the navigationBar, a button in the middle of view to push to second viewController.
The second viewController has a left bar button item to pop to the first viewController.
If the second view controller has been dragged less than 50%, my custom animation will cancel the transition, and if it's over 50%, it'll finish the transition, pop the viewController. (Just like the system default)
However, if the transition was cancelled, the navigation item's on the first view controller will be over-ridded.
The "back" item will appear on first view controller, and the right bar button item will disappear.
This is the video to demonstrate: https://youtu.be/qg2lUKsNtzk
And the source code is on github: https://github.com/JohnnyTseng/issue5-view-controller-transitions
Could somebody point out where the problem is? I've been debugging this issue for whole day. Thanks!
In iOS 7 Apple add new default navigation behavior. You can swipe from left border of the screen to go back on navigation stack.
you can stop this by putting this code in application delegate.
if ([self.navigationController respondsToSelector:#selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
you can read more over here interactive pop gesture of navigation view controller

iOS Navigation Controller doesnt add navigation bar

My situation: http://i.stack.imgur.com/KTlVu.png
I have two views right now. From the second view, I want to have a back button that goes back to the initial view. I added a navigation controller and made it the initial view, and the navigation bar appeared for the first view(PlusCalendar). However, I don't know how to add a navigation bar for the second view(AddEventControllerVC) and add a back button that makes it go back to PlusCalendarView. I have looked at several tutorials and none of them surprisingly dealt with this problem. I am also looking at Apple's class reference and I am not sure if I have to initialize the navigation bar again from the second view controller. My questions are..
How come a navigation bar is not automatically added to all of my views?
For the second view, why does the navigation bar seem to be placed at the bottom?
How do I add a navigation bar on top of the second view, and add a "back" button?
The navigation bar was supposed to add the back button automatically. The problem was that the sigue between my first view and second view was set as a "modal popover." When I changed it to a "push" the back button appeared rightfully.
It seems that in model pop, the navigation bar is not record the view controller in its stack. So it cannot known the back track.In your case ,you should custom your navigation items in the second view controller. You can look this example: custom navigation bar

Transitioning between transparent navigation bar to translucent

In Apple's recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven't been able reproduce it. When popping the Now Playing view controller the navigation bar remains transparent for the Now Playing view controller and the navigation bar for the library view controller also stays translucent (Screenshot 1). I'm trying to figure out if they are using two navigation controllers or only one. Personally I feel they're using just one for two reasons (1) the interactive pop gesture is enabled; (2) when you press the 'Now Playing' button in the library view controller, just before the now playing screen has finished 'push view controller' animation the navigation bar becomes transparent (Screenshot 2). This is the behaviour I experience when pushing my view controller (which sets the navigation bar to transparent). So my question is: How does Apple present both navigation bars of the two view controllers as if they were individual (as with Screenshot 1), even the bar buttons, navigation title etc... are 100% in opacity when switching (usually when pushing/popping the buttons and titles of the previous view controller fade as the new controller is being pushed). I've tried playing around with the bar tint colour in viewDidAppear and viewWillAppear in both view controllers but cannot reproduce the same behaviour, and cannot prevent the bar buttons from fading.
Gosh I hope I've explained this well, I get confused just thinking about it!
Screenshot 1 (Popping):
Screenshot 2 (Pushing):
I just downloaded the application to make sure. Two different navigation bars are used. You can see this by using the interactive pop gesture. Notice how the navigation bar on the bottom view controller slides in and out. During normal push and pop transitions, the navigation items just fade in and out on the existing bar, while the bar is stationary. This is what happens up until the point where the now playing view controller is pushed.
If you look quickly, during the now playing view controller animation, you can see the bottom navigation bar disappear.
From my experience with UIKit behavior and what I see in the app, here is what I think happens:
album_vc = the bottom, list view controller
nowplaying_vc = the top view controller
On nowplaying_vc's viewWillAppear:
Set the navigation bar to hidden using [self.navigationController setNavigationBarHidden:YES animated:YES];. Since this is in animation block, this will make the navigation bar slide out during the push animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; Pretty sure about this, because notice there is no animation in the transition of the status bar styles. It just becomes white.
On nowplaying_vc's viewWillDisappear:
Set the navigation bar to shown using [self.navigationController setNavigationBarHidden:NO animated:YES];. Since this is in animation block, this will make the navigation bar slide in during the pop animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; Again, notice how during interactive pop gesture, the status bar just changes with no animation.
To achieve the transparent look of the navigation bar of nowplaying_vc, you can use an empty image ([UIImage alloc]) with setBackgroundImage:forBarPosition:barMetrics:.
Since the application does not rotate, we can't be sure if the navigation bar on nowplaying_vc is part of another navigation controller or just a navigation bar on the top with a position of UIBarPositionTopAttached. For all we know, there isn't even a navigation bar there but just a back chevron image view (back bar button is comprised of an image view and a button).
I think the status bar style is changed in viewWillAppear: and viewWillDisappear: due to the unnatural feel there is during interactive pop gesture. I would recommend using an animated transition, or even better, use the new view controller-based status bar style, which the system animates transitions by itself.
Update for modern API:
You should use the animateAlongsideTransition:completion: or animateAlongsideTransitionInView:animation:completion: API, rather than relying on the implicit animations of viewWillAppear: and viewWillDisappear:.
Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.
On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.
Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

Modal Segue Into Navigation Controller with No Nav Bar

In my storyboard I have a view with a segue into a new view that's embedded into a Navigation Controller (so the segue points to the navigation controller). I have the segue set to a Modal transition, however when the new view is animating up, it contains the standard blue navigation bar above the view (which then animates out of view).
Here's what it looks like mid segue: http://i.imgur.com/3eqAQ.png
How do I make it so the modal view animates up but without the navigation bar?
I have tried hiding the navigation bar in the embedded view's init, viewWillAppear, and vieWillLoad methods and that doesn't work.
I event went so far as to create a custom subclass of UINavigationController and set the navigation controller in the storyboard to it.
Thanks!
This may sound pretty simple, but have you tried hiding the navigation bar immediately before the modal segue starts? I had this problem when presenting a modal view controller and adding a [self.navigationController setNavigationBarHidden:YES] immediately before the presentation did the trick for me.
I had almost the same problem, but I wanted to get a navigation bar for my modal transition, as it was always hidden.
There may be two ways for you to remove the navigation bar:
Make sure that your view controller is not embed in a navigation controller, as it would put one by default
Check the "Top Bar" attribute of your previous controller in the workflow and work with none/inferred values depending on your storyboard.
Regards

Resources