Questions tagged [uitabbarcontroller]

The UITabBarController class implements a specialized view controller that manages a radio-style selection interface. This tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is but may be subclassed in iOS 6 and later.

The UITabBarController class implements a specialized view controller that manages a radio-style selection interface. This tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is but may be subclassed in iOS 6 and later.

Each tab of a tab bar controller interface is associated with a custom view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views. (User taps always display the root view of the tab, regardless of which tab was previously selected. This is true even if the tab was already selected.) Because selecting a tab replaces the contents of the interface, the type of interface managed in each tab need not be similar in any way. In fact, tab bar interfaces are commonly used either to present different types of information or to present the same information using a completely different style of interface. Figure 1 shows the tab bar interface presented by the Clock application, each tab of which presents a type of time based information.

enter image description here

You should never access the tab bar view of a tab bar controller directly. To configure the tabs of a tab bar controller, you assign the view controllers that provide the root view for each tab to the viewControllers property. The order in which you specify the view controllers determines the order in which they appear in the tab bar. When setting this property, you should also assign a value to the selectedViewController property to indicate which view controller is selected initially. (You can also select view controllers by array index using the selectedIndex property.) When you embed the tab bar controller’s view (obtained using the inherited view property) in your application window, the tab bar controller automatically selects that view controller and displays its contents, resizing them as needed to fit the tab bar interface.

Tab bar items are configured through their corresponding view controller. To associate a tab bar item with a view controller, create a new instance of the UITabBarItem class, configure it appropriately for the view controller, and assign it to the view controller’s tabBarItem property. If you do not provide a custom tab bar item for your view controller, the view controller creates a default item containing no image and the text from the view controller’s title property.

As the user interacts with a tab bar interface, the tab bar controller object sends notifications about the interactions to its delegate. The delegate can be any object you specify but must conform to the UITabBarControllerDelegate protocol. You can use the delegate to prevent specific tab bar items from being selected and to perform additional tasks when tabs are selected. You can also use the delegate to monitor changes to the tab bar that are made by the More navigation controller, which is described in more detail in The More Navigation Controller.

For more information about using tab bar controllers to build your user interface, see View Controller Programming Guide for iOS.

The Views of a Tab Bar Controller

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. The view for a tab bar controller is just a container for a tab bar view and the view containing your custom content. The tab bar view provides the selection controls for the user and consists of one or more tab bar items. Figure 2 shows how these views are assembled to present the overall tab bar interface. Although the items in the tab bar and toolbar views can change, the views that manage them do not. Only the custom content view changes to reflect the view controller for the currently selected tab.

enter image description here

The More Navigation Controller

The tab bar has limited space for displaying your custom items. If you add six or more custom view controllers to a tab bar controller, the tab bar controller displays only the first four items plus the standard More item on the tab bar. Tapping the More item brings up a standard interface for selecting the remaining items.

The interface for the standard More item includes an Edit button that allows the user to reconfigure the tab bar. By default, the user is allowed to rearrange all items on the tab bar. If you do not want the user to modify some items, though, you can remove the appropriate view controllers from the array in the customizableViewControllers property.

State Preservation

In iOS 6 and later, if you assign a value to this view controller’s restorationIdentifier property, it preserves a reference to the view controller in the selected tab. At restore time, it uses the reference to select the tab with the same view controller.

When preserving a tab bar controller, assign unique restoration identifiers to the child view controllers you want to preserve. Omitting a restoration identifier from a child view controller causes that tab to return to its default configuration. Although the tab bar controller saves its tabs in the same order that they are listed in the viewControllers property, the save order is actually irrelevant. Your code is responsible for providing the new tab bar controller during the next launch cycle, so your code can adjust the order of the tabs as needed. The state preservation system restores the contents of each tab based on the assigned restoration identifier, not based on the position of the tab.

For more information about how state preservation and restoration works, see App Programming Guide for iOS.

6522 questions
2
votes
0 answers

Custom animation when switching tab/viewcontroller in UITabBarController

I'd like to make a UITabBarController tab switching animation similar to pop and push animation of navigation controller. That's means if I select a tab at the left of the current tab, the view of new viewcontroller move into the screen from the…
ThinkChris
  • 1,169
  • 2
  • 15
  • 38
2
votes
1 answer

How to change the TabItem manually in iPhone?

I am using TabbarController. When I am in the first tab all other tabItem in a disable mode and I have one button in the first tab viewcontroller, on clicking that button it should move to the second tabitem. I have implemented setselectedindex but…
Uma rajendran
  • 287
  • 1
  • 4
  • 18
2
votes
4 answers

Statusbar overlaps ViewController

I in my AppDelegate, I use: ActivitiesViewController *acController = [[ActivitiesViewController alloc] initWithNibName:@"ActivitiesView" bundle:[NSBundle mainBundle]]; UINavigationController *acNavController = [[UINavigationController…
Stefan
  • 28,843
  • 15
  • 64
  • 76
2
votes
3 answers

How to create a tab bar on iOS?

I need on my main view controller to have a tab bar with tabs to navigate to all my other controllers. I just need the tab bar on this controller and when i get to another controller i just need to have a back button to go to the main…
user1511244
  • 725
  • 3
  • 11
  • 15
2
votes
2 answers

iOS - Portrait Locked Tab Controller App Won't Allow Landscaped Movie Player

I have an app that is purely a Tab Bar Controller with 5 tabs (views). I want those views to be portrait only. However, the app does allow video clips to be played and uses an MPMoviePlayerViewController to do so. But I can't get the player to…
2
votes
2 answers

Disable edit button from more tab bar application

I am using Storyboard to create a tab bar which has 6 tabs. The tab bar is the initial view controller. I am not using any custom class for my tabbarcontroller. The more tab gets a "edit" button. How can I remove that button?
zahreelay
  • 1,742
  • 12
  • 18
2
votes
0 answers

Possible to create UITabBarController w/ Custom Images, Pressed/NotPressed?

I want to add a little flair to my application and while I have been somewhat successful, I haven't figured out a way to truly do what I want to do. I would try to subclass UITabViewController, but I don't think I would even know where to start or…
TheAggie
  • 57
  • 1
  • 10
2
votes
1 answer

"self.navigationItem.hidesBackButton = YES" not working with UITabBarController

I have a UINavigationController with a UITabBarController nested within it. I'm trying to hide the back button in the navigation bar so that I could replace it with a custom button. But I can't seem to do this once one of the tabs is the active…
2
votes
3 answers

Transparent UITabBarController with changeable view in background

I want to have a UITabBarController, which is has an alpha of 0.5, whose transparency allows you to see a view in the background. The background view has to be accesible and changeable. I'm able to add the background using this technique:…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
2
votes
4 answers

Rotating UITabBarController Icon

I have an UITabBar in my application. One of the tab bar icons looks like a loading symbol. When the user presses the loading button I want the icon to spin/rotate until the loading is done. Should I use UIImageView to animate or something else? How…
Jacob
  • 1,310
  • 1
  • 15
  • 29
2
votes
0 answers

iOS customize morenavigationcontroller

I want to add an UIImageView on the top of the UITableView generated in the MoreNavigationController. To do this I need to change the UITableView's position and size. Here is the code I tried: UIImageView *img = [[UIImageView…
Mehdi
  • 974
  • 1
  • 10
  • 24
2
votes
2 answers

Storyboards - UISplitViewController with a UITabBarController in the Detail

I am trying to set up a UISplitViewController in a Storyboard with the detail going to a UITabBarController which then goes to a UINavigationController wrapping my first ViewController. The problem I am having is getting the UIBarButtonItem to show…
ryanbillingsley
  • 215
  • 4
  • 12
2
votes
1 answer

UITabbar Controller

In my app i am using tabbar controller with 5 tabs,in 3 tabs,when click on a button it calls one View Controller. I am using same view controller for those 3 tabs so i am getting problem while calling same view in different tabs,So while changing…
ganesh manoj
  • 977
  • 10
  • 24
2
votes
1 answer

can anybody guide me how the instagram application created the view of login and tabbar in iphone sdk?

hi can any body guide me how to display the login screen like instagram , pinterest and other social networking app like picyou they show login screen like this before login and after login i think this are two different view or just they have…
2
votes
1 answer

Launch configuration wizard on startup in UITabBarController based application

I have a UITabBarController based application. I want to launch a configuration guide - a series of views - the first time the application is launched. That of course have nothing to do with with the normal tab navigation and I want the…