UITabbar nothing selected - ios

U have got an UITabBar (not an controller) when I select an element, How can I change the UITabBar such that nothing is selected any more?

myTabbar.selectedItem = nil; // will remove selection

Related

UITabbar View overlap title on image after present the another UIViewController

I am using the UITabbarview with for item. For every tabbar item I am using the image and title.
Its perfect when I come that TabbarViewcontroller screen and navigate to another to anther UIViewcontroller by push.
But if i navigation to another UIViewController by present then come back to same TabbarviewController screen then title overlap on image of bar item.
like the images
Now I am not able to understand, why this happening and how to resolve this issue.
use this code in your "viewWillAppear" method.
-(void)viewWillAppear:(BOOL)animated
{
[UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0, -3);
}
Select tab bar icon and choose image inset all = 0

iOS How to implement Tab Bar View Controller with no tab bar item selected?

I have gone through almost all question related to this on Stack Overflow
What I what to do is to show TabBarViewController as in the image.
Is there any way to achieve this in my tab bar view controller app?
NO, there needs to be at least one Tab selected. By default the Tab bar will select the first view controller object.
if you want to use Tabbar more flexible, you can use a customView instead of TabBarViewController's tabor, just like:
UIView *customTabBar = [[UIView alloc] init];
customTabBar.frame = self.tabBar.bounds;
[self.tabBar addSubview:customTabBar];

Hide back button of navigation bar in Story board iOS

I would like to hide back button of navigation bar which is a part of Story board, I have tried different following code snippets in detail view button nothing seems to work for me.
self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem=nil;
PS: I am also having tab bar along with navigation bar in my story board
Add this line in the viewDidLoad of your ViewController where you would like to hide the back bar button:
[self.navigationItem setHidesBackButton:YES];
Tested successfully in a storyboard project.
Try this
self.navigationItem.hidesBackButton= YES;
If you have added your own button to the navigationController and want to hide that as well (such as while editing text), its a two line process like this:
myViewController.navigationItem.leftBarButtonItem = nil;
myViewController.navigationItem.hidesBackButton=YES;
You can hide the entire navigationbar as follows:
self.navigationController.navigationBar.hidden = YES;
then in your storyboard you can add a navigation bar to your view controller.
The result is what you want but maybe users will be confused as to why they can't go back...
Its too late answer but may help others.
To hide back button you can do this :
self.navigationController.navigationItem.leftBarButtonItem.hidden = YES;
You can also try with :
self.navigationItem.leftBarButtonItem.hidden = YES;
This actually hides left BarButton and back button is on left side, too, unless you change programmatically.

How to set first TabBar selected programmatically on iPhone

I have UITabBar in view which have 5 tabs. I am using didSelectItem delegate to open different view i.e. I am NOT using TabBarController.
My problem is on view load I need first tab get selected by default. Is there any property in TabBar which we can set to make it selected?
Thanks.
This code will work [tabBar setSelectedItem:[tabBar.items objectAtIndex:0]];
In swift if tabbar is used not tabbarcontroller set default select
var tabbar:CustomTabBar?//if declare like this
tabbar!.selectedItem = self.tabbar!.items![0] as? UITabBarItem
or
let tabbar = UITabBar()//if declare and initilize like this
tabbar.selectedItem = self.tabbar.items![0] as? UITabBarItem
set the
tabbar.selectedItem=0; in the viewWillAppear so when ever the view appears it will select the first tab by default.
[self.tabBar setSelectedItem:self.tabBar.items[0]];
or
self.tabBar.selectedItem = self.tabBar.items[0];
The selectedItem property requires a TabBarItem and not an index. So provide the tabbaritem in index 0 for the first tab.
This is wrong then: tabbar.selectedItem=0;
You may select other tabs as well. Happy coding

how can i set the badge in tab bar in objective-c?

I want to put the notification in the tab bar of the app to show the number of item selected for the shopping list.
Is there any way to add the notification in the tab bar of app.
You mean the badge? Do something like (where self is a UIViewController):
[[self tabBarItem] setBadgeValue:#"42"];
On the storyboard you have to select your navigation view controller if you have and then open your Property window and set Badge according to your requirement.
if you want to set programmatically
1. find your tabbar Item by viewcontroller
# badge=what you want to set.
2.[[[[self tabBarController] tabBar] items] objectAtIndex:1] setBadgeValue:badge];
and if you want to set by storyboard please refer this image.
Hope this will helps.
Thanks
Also if you want to use in swift. Below code will work for you
[[self tabBarItem] setBadgeValue:#"42"];
You can set the badgeValue property on a UITabBarItem to present the user with a small red badge on that item.
I did it using:
self.navigationController.tabBarItem.badgeValue = #"2";

Resources