Unable to remove BackButton in Navigation controller using Storyboard in ios - iphone

I am new to iOS,
I am developing shopping App for IPhone using Storyboard,
Here is the snapshot of my App,
TabBarController contains 4 Tab with NavigationController
When i open Tab1(let say class1) it contains TableView, onclick of tableview it will take me to Detail page with title and back button on NavigationBar (I am adding title and back button programatically in ViewWillAppear method) after this when i hit back button i navigates to previous page properly, this is working fine..
My problem is When i open Tab1(i.e class1) and when i navigates to Detail page after selecting a row in tableview, in a Detail page, BackBtn and title will be added in NavigationBar bcoz ViewWillAppear method will be called, and when i hit Tab2 before hitting Backbtn, i am navigates to class of Tab2 and thn when i comes back to Tab1 and now i clicks on back button i am navigating to previous page of my Tab1 class (i.e class1) but on class1 back Button and title of Detail page is there on my class1 i am unable to hide it...
You can see in the 2nd image BackBtn and Title is there in Class1..
What's the problem ?

just hide that backButton in viewWillAppear: method of Class1 like bellow...
[self.navigationItem setHidesBackButton:YES animated:YES];
or
[self.navigationItem setHidesBackButton:YES];
UPDATE:
if you add custom button to the UINavigationBar then just remove that button like bellow...
self.navigationItem.leftBarButtonItem = nil;
and if you want to remove right bar button then use bellow another code like above...
self.navigationItem.rightBarButtonItem = nil;
i hope this helpful to you...

[btnBack setHidden:YES] in viewWillDisapper: method in Detail page

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
Will give you which item you are currently selecting.
You can work around if you cant fix it by popping to root view controller and pushing it again. And make sure you are not adding a subview in place of pushing a view controller.

Related

UITabbarController with MoreNavigationController , PoptoRootViewController issue

Kindly help me with this issue .
I am using tabbarcontroller in my App,
[tabBarController setViewControllers:tabs];
tabs Contain array of viewcontrollers (6 viewcontrollers).
It automatically created more button.
ISSUE
When I open any viewcontroller from more button and then open any other controller from index 0 to 2 , and then press more button it maintain the last opened viewcontroller .
For Example:
more button tableviewcontroller
screen :
Now when i press Contacts let say
Now when user press any other tabbar like feature tab bar
Now when user go back to more tab it shows the contact's viewcontroller
But i want the app to poptorootviewcontroller when user back again to more tabbar , and simply more tableviewcontroller.
You can do this by in the ViewWillDisappear method of view controller in More tab, call method to pop this view out of MoreViewNavigationController, like this:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController popViewControllerAnimated:NO];
}
May be too late but here it is for future reference
UITabController has a tabBar property and it has a delegate which tells you when a tabitem is tapped
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
Tab bar also has another property "items" which lists the visibile tabs. Find the index of the selected tab item in items in the delegate method implementation and if the index is 4 which is more button then call tab [controller.moreNavigationController popToRootViewController]

Hide BackButton in UINavigation bar

i am pushing a View om RootView controller ,i get the navigation bar with back button which is navigate to rootviewcontoller,but i don't need this back button.i pout this code in the viewcontoller to hide the back button
self.navigationItem.hidesBackButton = YES;
so i get the hidden back button,but here is the problem,i need leftnavigationbar button to show something,when i write the above code ,the letbarbutton also hidden from the view.becz the leftbarbutton act as the back button.
My need is to block the letbarbutton to become a back button when push from the rootviewcontroller,i didn't need a navigation back to rootviewcontoller.But defenitly need leftbarbutton there for my need in the view.
How can it possible to do?.Please help me to do this.
Thanks in advance.
try this.
self.navigationItem.backBarButtonItem = nil;
it works for me
Why don't you just set the letbarbutton and add no action to it?

Navigation Issue with UITableView

How do I navigate back to the previous page with a UITableViewController. I tried to show a navigation bar with navigation button at the top of the screen, but the navigation bar will not show. I know that you have to give the previous view a title but when I go to do that it does not show anything. Also, since it is a UITableViewController I am not able to drop a navigation bar and add a button to the main view. All I would like to do is display my lists and have the option to navigate back to the previous list with a single button in the upper left corner.
The problem you having with the NavigationController is that your tableViewController is not in the NavigationController hierarchy. Want you want to do this when adding the tableViewController:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourTableViewController];
Then you can do this to add yourTableViewController:
[self.view addSubview:navigationController.view];
If you don't want the navigationBar to appear on the tableViewController just use:
self.navigationController.navigationBarHidden = YES;
in yourTableViewController viewWillAppear method.
When your going to add the view after the tableView you just use:
[self.navigationController pushViewController:someViewController animated:YES];
It's not enough to give the child view a title. You need to give the child view's navigation item a title before you present it. For example, in the parent view, before you push the the view to the navigation stack, do something like this...
[MyChildView.MyNavigationItem setTitle:#"A cool Title"];
For the navigation you are trying to achieve you should be using a UINavigationController. It already has the functionality you describe with the navigation bar and back button built into it.
To move to the next screen (which can be a UITableViewController) you use pushViewController:animated: and to move to the previous screen you use popViewControllerAnimated: (although the built in back button will do this for you).
I suggest reading the UINavigationController class documentation if you are not already familiar with it.

UINavigationBar Backbutton quits app

I have a Navigation Controller in my app delegate that i am using to switch between views and that seems to work fine clicking the back button in the NavigationBar, but only when i have a UITable in the mix. But when i pushRootviewController to a standard root view controller i still see the back button in the UINavigationBar but when i click it the program quits and logs no errors.
I thought maybe something like this would work, but no luck.
CoCoachAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UIBarButtonItem *iButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleBordered target:self action:#selector(playThis:)];
appDelegate.navigationController.navigationItem.backBarButtonItem = iButton;
[iButton release];
Anyone have something similar happen? Any ideas?
Thanks!
Your problem is that you set the button to the navigation controller itself. you should be setting the button to the navigationItems of your Controllers inside your Navigation Controller (and remember that the backBarButtonItem is displayed on the navigation bar when the next (follow-up) view controller is visible. if that is not the behaviour you want, you should use leftBarButtonItem.) also remember that "back buttons" should have target/action set to nil as the navigation controller adds itself als target when you use it as backBarButtonItem.

How to get this kind of back button in iphone

I am new to Objective-C, can anyone tell me how to get this kind
of back button on the navigation bar, on click of that it should navigate to previous page.
It is default back button style of Navigation-based application.
You can use it by selecting Navigation-based application when creating new application.
After created the application, you must set title of the view.
That view title will be the title of back button.
If you have no title of previous view, the back button will not appear automatically.
You can push view like this:
if (settingViewController == nil) {
settingViewController = [[SettingViewController alloc] initWithNibName:#"SettingViewController" bundle:nil];
}
[self.navigationController pushViewController:settingViewController animated:YES];
In this case, navigationController is already created by Xcode and you must prepare settingViewController(.h, .m, .xib).
Try this ..
[self.navigationController popViewControllerAnimated:YES];
it will get back to previous page ..
You can do as BoltClock had said.
and you can also set this title
go to the class where you have defined your navigation controller
and then go to the xib file..
in that in your navigation controller there is a option of navigation item select that
now go to attribute inspector and write down the title you wish to use
best of luck