Monday, June 10, 2013

UITabBar beginCustomizingItems example in Objective C (iOS).


UITabBar beginCustomizingItems

Presents a modal view allowing the user to customize the tab bar by adding, removing, and rearranging items on the tab bar.

- (void)beginCustomizingItems:(NSArray *)items

Parameters of [UITabBar beginCustomizingItems]
items
The items to display on the modal view that can be rearranged.
The items parameter should contain all items that can be added to the tab bar. Visible items not in items are fixed in place—they can not be removed or replaced by the user.

Discussion of [UITabBar beginCustomizingItems]
Use this method to start customizing a tab bar. For example, create an Edit button that invokes this method when tapped. A modal view appears displaying all the items in items with a Done button at the top. Tapping the Done button dismisses the modal view. If the selected item is removed from the tab bar, the selectedItem property is set to nil. Set the delegate property to an object conforming to the UITabBarDelegate protocol to further modify this behavior.

UITabBar beginCustomizingItems example.
Well, then it's a good thing that UITabBar has this functionality built in. Take a look at the following method:

UITabBar *mybar = [[UITabBar alloc] init];
[mybar beginCustomizingItems:[NSArray arrayWithObjects:tabItem1, tabItem2, nil]];

End of UITabBar beginCustomizingItems example article.