How to hide this back button? - ios

I want to hide this back button drop down every time I swipe rightwards.How is this possible?
I need a code which I can use it in AppDelegate so that i can use it globally rather than changing it for every ViewControllers.

Select your Navigation Controller and Uncheck Shows Navigation Bar as per below Image

self.navigationItem.setHidesBackButton(true, animated:false);

Well this code works in Appdelegate or in any ViewController.
In action of swipe rightwards add following line of code:
[[self navigationController] setNavigationBarHidden:YES animated:YES];
If you want to show it again use following code in appropriate method:
[[self navigationController] setNavigationBarHidden:NO animated:YES];

Related

Popping View Controller causes Bar Button Item to disappear

I have two ViewControllers in my app. The first ViewController (say, ViewControllerOne) has a Bar Button Item that has a slide in TableView (irrelevant to the question). I have disabled the Navigation Bar in the second ViewController (say, ViewControllerTwo) and added a custom view and a Button. I have written the code to pop ViewControllerTwo in thee action of the button. But once it is popped, the BarButton Item in ViewControllerOne disappears.
here is the code I have written in ViewControllerTwo
[self.navigationController setNavigationBarHidden:YES animated:YES];
And
- (IBAction)backCustom:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
Any idea why the Bar Button Item would disappear because of this? I am sure this code is the reason because, When I remove it, it runs fine with the default NavigationBar.But I need a custom one for my project
in your first Viewcontroller add the following line
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

UINavigationController back button return to FIrstTableViewController

So I was create three UITableViewControllers with UINavigationController. I want a back button on 3rd UITableViewController, what returns my view to first UITableViewController instead of second.
How can I do that? That must be a real backButton, not a image or something else. Will be perfect to do this only with storyboard.
UPDATE
Perhaps I poorly explained what I want.
I don't want use any button with action on it. I just want something like as setting "address" of 1st TableViewController on my default back button. There is any way to do it?
add a button and connect it to following action
- (IBAction)backToFirstView:(UIButton *)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
(or)
[self.navigationController popToViewController:yourFirstViewControllerObject animated:YES];
}
There are different ways to navigate from DetailViewController to other view controllers.
We will go through the cases one by one.
First of all I would like to clear that if its your default
navigation bar's back button, then it must return to the last most
view controller only which is actually a default behavior of a
navigation controller.
Second, If you would like to go back to the
last most view controller on the tap of a button placed by you, you
should write the following code
[self.navigationController popToViewController:NAME_OF_A_VIEWCONTROLLER animated:YES];
Third, If you would like to go to the first view controller from where you
started, you should write the following code
[self.navigationController popToRootViewControllerAnimated:YES];
Ok, I found a way to resolve my problem. Thanks for your answers guys, they was very helpful.
So for resolve this problem you just need use link what give me Kumar KL upper, and wrote next method in your UITableVIewController
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// Navigation button was pressed. Do some stuff
[self.navigationController popViewControllerAnimated:NO];
}
[super viewWillDisappear:animated];
}
Now you got a backButton what redirect you to your viewController, BUT title of this button is wrong. Let's resolve that unfair.
Create new class CustomSegueцрфе inherited from UIStoryboardSegue with next code in CustomSegue.m :
- (void)perform
{
UIViewController *sourceView = (UIViewController *) self.sourceViewController;
UIViewController *destinationView = (UIViewController *) self.destinationViewController;
[[destinationView navigationItem] setTitle:#"TitleOfYourViewController" ] ;
[sourceView.navigationItem setTitle:#"TitleOfButton"] ;
[sourceView.navigationController pushViewController:destinationView animated:YES];
}
Now you can go to storyboard and connect 2nd ViewController with 3rd with custom segue.
Like you see UINavigationController uses Title of previous ViewController for button title, so you just need change it.

Objective C - navigation button without animation but with option to Perform back

I'm kind new in all the Objective C stuff so try to understand :)
i want to use a navigation button to move to the next view but without any animation.
and i need to save the Current info in the source view and be able to have back button in the destination view.
in modal style i can't save my info and when i'm back to the screen all the info disappeared.
in push style i can use the back button but i cant stop the animation.
in custom style i didn't make it either
help?
btw - please try to give specific answer so i can understand :) THNKS
If you are having navigation controller you can easily do this by pusing viewController to current navigation stack. If you don't want to navigate with an animation you can pass NO to animated value like this.
[self.navigationController] pushViewController:controller animated:NO]; If you want pass YES.
Now when ever you will push view controller you will get a back button, its navigation controller duty to create it for you. Title of this button will be same as source view controller title, if there is no title button title will be back.
Now how you can do that, add a button to your source view controller and assign an action. Call this code in action of that button.
You can add button by interface builder and can set action by clt+drag to source file. Or you can add that button by code.
if you want to do it by code add this in viewDidLoadMethod
UIButton *next = [UIButton alloc] init];
[next setTarget:self action:#selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
And then add btnClicked method in
- (IBAction)btnClicked:(id)sender{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
Second* controller= (Second*)[storyboard instantiateViewControllerWithIdentifier:#"Second"];
[self.navigationController] pushViewController:controller animated:NO];
}
Edit
It would be better first you go to this link and read some basics.
You can use a UINavigationController to posh/pop all your view controllers. You can control the animation using
[[self navigationController] pushViewController:controller animated:(NO)];
or
[[self navigationController] popViewControllerAnimated:controller animated:(NO)];
I hope that helps. Here is a tutorial on using UINavigationController
http://bharanijayasuri.wordpress.com/2012/12/19/simple-uinavigationcontroller-tutorial-2/

how to hide tabbar when I use NavController to push view?

I have tried two kinds of methods below:
1.[self.tabBarController.tabBar setHidden:YES];
2.
self.navigationController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:OneViewController animated:YES];
But the result is that the tabbar items is hidden, but there is still a black block there,
I guess it is because the view's tab bar style is not set to None.Just like the IB's view setting below:
How to solve this problem, thx
To hide the nav bar use this code
[[self navigationController] setNavigationBarHidden:YES animated:YES];
To show the nav bar you can use this code
[[self navigationController] setNavigationBarHidden:NO animated:YES];
And here is the doc's that might be helpful my friend
https://developer.apple.com/library/ios/ipad/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
Hope that helps you man.
EDIT
Here is a github project for hiding the tab bar. Hope this helps you.
https://github.com/idevsoftware/Cocoa-Touch-Additions/tree/master/UITabBarController_setHidden
Let me know if this is what ou are looking for and if you need more help man.

XCode/iOS: setToolbarHidden:animated creates new unwanted toolbar?

I'm trying to achieve something similar to user of this post:
Xcode/iOS: How to hide Navigation- AND ToolBar on scroll down?
I'm able to hide (or unhide using NO) the navigation bar successfully using the code:
[[self navigationController] setNavigationBarHidden:YES animated:YES];
However, when I attempt to hide the toolbar using the code:
[[self navigationController] setToolbarHidden:YES animated:YES];
Nothing happens. I then noticed when unhiding the toolbar that I received an additional blue toolbar that I didn't realize existed. This screenshot shows this:
Screenshot
I do not want the blue bar. What I am trying to do is hide or unhide the Black toolbar with the icons on it. (the UITabBar).
I think what I need to do is somehow I need to access the navigation controller of one of the parent view controllers and call the setToolbarHidden on the navigation controller of that view. However, I can't seem to figure out how to do this.
I've tried the following and all seem to have no effect:
[[[self parentViewController] navigationController] setToolbarHidden:YES animated:YES];
or
[[[[[[UIApplication sharedApplication] delegate] window] rootViewController] navigationController] setToolbarHidden:YES animated:YES];
My view controller storyboard consists of the following:
The InitialViewController is a TabBarViewController. It contains three children. One of those children is a UINavigationController. This navigation controller gets several UITableViewController pushed onto it, and eventually a UIViewController is pushed. This last UIViewController is what is seen in the screenshot.
Rough Layout:
TabBarViewController
UIViewController
UITableViewController
UINavigationController
UITableViewController
UITableViewController
UITableViewController
UIViewController
I've tried using
[self parentViewController] parentViewController] parentViewController] ...
to attempt to get back to the top, but this hasn't seemed to work either.
Any suggestions?
I think the problem here might be related to UITabBarController not having a UIToolbar. The setToolbarHidden: method will only apply to the UINavigationController's built-in toolbar (see Apple's documentation). If it's the UITabBarController's tab bar that you actually want to hide, take a look at this post which links to a method using UIView animations directly on the UITabBar.

Resources