Search code examples
iosobjective-cswiftuitabbar

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.


Solution

  • This code will work [tabBar setSelectedItem:[tabBar.items objectAtIndex:0]];