A button is added to the navigation bar which is shown on all the screens. I need to hide it from all screens except one - objective-c

In my app for iPad, I have first a welcome screen then home screen and then home screen navigates to rest of the screens. I have made a button on navigation bar of the home screen which takes the user back to the welcome screen. But that button is shown on all other screens as well. I want to remove that button from all the screens and show it only in the home screen. How can I hide that button from all other screens and make it visible only on the home screen?
Thanks PC

In viewDidDisappear:
self.navigationItem.rightBarButtonItem = nil;
// or on whichever side your button is
In viewWillAppear:
self.navigationItem.rightBarButtonItem = self.showWelcomeButton;
// self.showWelcomeButton is a retained UIBarButtonItem property

Related

MMDrawerController - Open Left Drawer from a button in Center Drawer

I've created a MMDrawerController within my app delegate file and I'm having trouble trying to toggle open the left drawer from an action within the center view. Is this a possible thing to do?
You can use this code in click event of your center view button.
[self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
This mm_drawerController object is your MMDrawer object.

Hiding (not removing) A UITabBarController UITabBarItem

I need to hide a button on the tab bar, but still have it accessible by code as needed. I know I can completely remove the button, but then I cannot access that view anymore.
So in my case, I want my home screen to be visible when the app first loads, but do not want the tab to show up for it. If they navigate away from that screen, I will add a custom "home" button in the navigation bar at the top.
However, if I remove the tab bar item, I no longer go to the home screen anymore but to what was originally the 2nd tab. Is there a way to only hide the tab bar item and still access it in code?
So you can see how I'm accessing the tab bar to begin with, here is how I can remove the tab bar item.
UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;
NSMutableArray *tabBarViewControllers = [NSMutableArray arrayWithArray:[tabVC viewControllers]];
[tabBarViewControllers removeObjectAtIndex:0];
[tabVC setViewControllers:tabBarViewControllers];
//or to just disable it
NSArray *tbItems = tabVC.tabBar.items;
UITabBarItem *item_0 = [tbItems objectAtIndex:0];
[item_0 setEnabled:NO];
There is an option of hiding the bottom TabBar in the attributes inspector
"Hide bottom bar on push"
You might find this link useful
How to hide/show tab bar of a view with a navigation bar in iOS?

Navigation bar not displaying menu button for slide out menu

I have one issue ok. I have a slideoutnavigation in my app ok.
When the user logs in they are brought to the home page where the slideoutnavigation is there. The user should be able to swipe to the right to open the menu or click a UIBarButton to also open the menu. Now the swipegesture works but the UIBarButton is giving the option to go back to the login View controller.
Here is the code for when the user clicks log in
ParenHomePage *lvc=[self.storyboard instantiateViewControllerWithIdentifier:#"parentHome"];
SlideNavigationController *navcontroller = [[SlideNavigationController alloc] initWithRootViewController:lvc];
ParentMenu *leftMenuParent = (ParentMenu*)[self.storyboard instantiateViewControllerWithIdentifier: #"ParentMenu"];
//[SlideNavigationController sharedInstance].leftMenu = leftMenuParent;
navcontroller.leftMenu = leftMenuParent;
[self presentViewController:navcontroller animated:YES completion:nil];
Any help would be great guys thanks

UISearchBar in navigation bar from UIBarButton in iOS7

I would like to have my search bar launched from a UIBarButton that I have added to my navigation bar from the storyboard. I have also added the Search Bar and Search Display Controller to the document outline in my view controller from the storyboard.
If I implement the code below in my viewDidLoad method the search bar will automatically appear in my navigation bar self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
However, when I try and implement this in from a button click from my navigation bar nothing happens.
(IBAction)serachBarButton:(id)sender
{
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
}
The IBAction is properly hooked up to the view controller in the storyboard. Any code examples of how to launch the search bar from my navigation button click would be greatly appreciated.

iOS Left "More" UIBarButtonItem (in navigation controller) if UITabBar is hidden

In my ios5 application I have a TabBar, and for each tab I have a navigation Controller.
I have more than 5 tabs, but if I set HIDDEN to YES to my tab bar a UIBarButtonItem with text "More" will appear in my navigation bar (leftItemsSupplementBackButton is set to YES) to the left - only in rootViewControllers, and there's no way to get reference to this button.
Pressing this button it will go to moreNavigationController.
Any ideas how to hide this button?
The More Button is the back button standard will appear automatically if one of the > 4 tab bar item is selected, even if tab bar is hidden. The workaround to get hidden this button is to hide, only if view controller is rootviewcontroller, the back button:
self.navigationItem.hidesBackButton = YES;