Non-Animated Storyboard Segues - ios

I have an app in which there is a ViewController and once a button is pressed it goes to DetailViewController. In ViewController I have hidden the navigation bar to have more room to display an image while in DetailViewController it is necessary.
When I hit the back button in DetailViewController it goes back, however since it has a navigation bar and ViewController doesn't the animated segue looks bad. I was wondering, is there a way to make the default back button (that comes when embedded into navigation controller) give you a non animated segue?
Thanks

try using [[self navigationController] setNavigationBarHidden:{YES,NO} animated:{YES,NO}]; in view{Will,Did}{Dis}appear instead of setting everything up via Xcode UI controls
You can get good results WITH animation using them too.
If you really want to remove the whole animation, though: Prevent the animation when clicking "Back" button in a navigation bar?

Related

Back button does not appear in viewcontroller

I wish to simply add a back button to the view controller, when accessed from a TableView in my app.
I have embedded the resulting ViewController within the navigation controller, and the back button is simply supposed to appear as documentation notes, but it does not...
Remove the UINavigationController between FriendsViewController and IndividualChatController.
When you push a new navigationController, it creates a new navigation stack with its own navigationBar and therefore you don't see a back button in the navigationBar

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

add back button to first screen of navigation controller in iOS

I know that a push segue automatically adds a back button so that the presentee can return to the presenter on click. What I want is for the back button to be available on the first UIViewController of the NavigationController (basically the only view controller in the chain that does not have a back button). How do I force add the back button?
I cannot simply add a custom image because I want the exact same chevron that comes with the iOS back button.
The easiest (yet hackish) way to achieve this is probably adding a dummy view controller in the stack before the actual first one, so you will get a proper back button. Use dummy's backBarButtonItem to customize the button title if you need, and -viewWillAppear: to respond to the button being tapped.
What I want is for the back button to be available on the first UIViewController .... How do I force add the back button
This whole thinking and logic is wrong. This is not how iOS UINavigationControllers work. You have a starting page (mainViewController) in a UINavigationControllers and from there you "move on" to something else. But you always come back to the main view controller. Just think about it, if you put a back button on the main view controller, where will the user go back to?
If you have a situation like this.
SomeViewController --> UINavigationController --> MainViewController
Once user is on SomeViewController and you take him to MainViewController which is part of UINavigationController then back button makes sense.
Just a FYI - you can easily drag and drop a UIBarButtonItem to any UINavigationController in Xcode and call it "Back". You will have to then connect that back button to another view controller.
Maybe it doesn't make sense but why can't you add a custom image? If all you want is "Back" chevron, can't you take a screenshot of this button and then put this image on your custom UIBarButtonItem?

Fake UINavigation Bar

I'm making an app in Swift and even though i'm using a navigation controller, there is a particular point where I want to present a view controller rather than make a segue and have the viewController added to the navigation stack.
This view controller i'm presenting is completely disconnected from the rest of the storyboard (it gets reused by a few screens).
To "fake" that it's part of the navigation controller stack, I wanted to drag and drop a navigation bar onto this orphaned view controller, and then manually add a back button. I want to handle my own back functionality and then use self.dismissViewControllerAnimated(true, completion: nil) to go back.
The problem is that this navigation bar doesn't have the same height or feel as the traditional one - the back button is way up high almost hitting the carrier/bars of service/4g/LTE area, and the title is touching the top of the screen. It's too high.
If I manually move it down, it's height doesn't occupy the whole area and there is this weird white strip.
Any ideas on how I can drag&drop my own navigation bar and get it to look like the ones typically done when you have a navigation controller?
Thanks!
Can you wrap your controller in a navigation controller, and present the nav controller modally:
UINavigationController *modalNavcontroller = [[UINavigationController alloc] initWithRootViewController:youController];
[self presentViewController:mdalNavcontroller animated:YES completion:nil];

How to change a navbar UIBarButtonItem button to a navbar back button?

I have a UIViewController with a navigation bar i dropped in in storyboards. Then I dragged in a UIBarButtonItem which is rectangular.
I want that button to look like a navigation bar's back button
I was suggested to do this:
self.navBar.topItem.backBarButtonItem = self.button;
After properly creating the properties and connecting them to the outlet. I did but the button still looks like the Done Rectangular button. How can I change it?
Those buttons are created automatically when you do a push segue.
For your particular problem, you can call perform [self dismissModalViewControllerAnimated:YES] in the case of modal segues, or [self.navigationController popViewControllerAnimated:YES]; for dismissing custom push segues.
Anyway, I don't know any method to change the button style to the "left arrow", other than selecting a background image with your particular "button".

Resources