博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

tab bar interface

Posted on 2013-01-21 16:04  酸梅拯救地球  阅读(195)  评论(0)    收藏  举报

1. The tab bar controller creates and manages the tab bar view and also manages the view controllers that provide the content view for each mode.

2. Each content view controller is designated as the view controller for one of the tabs in the tab bar view.

3.The tab bar controller has its own container view, which encompasses all of the other views, including the tab bar view. The custom content is provided by the view controller of the selected tab.

4.

A standard tab bar interface consists of the following objects:

  

5.

   You do not modify the tab bar view directly. The tab bar controller object assembles the contents of the tab bar from the UITabBarItem objects provided by your content view controllers.

   For each content view controller in your tab bar interface, you must provide a UITabBarItem object with the image and text to be displayed in the corresponding tab.

  

 

6.Creating a tab bar controller

- (void)applicationDidFinishLaunching:(UIApplication *)application {
   tabBarController = [[UITabBarController alloc] init];
 
   MyViewController* vc1 = [[MyViewController alloc] init];
   MyOtherViewController* vc2 = [[MyOtherViewController alloc] init];
 
   NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
   tabBarController.viewControllers = controllers;
 
    window.rootViewController = tabBarController;
}

7.   Creating the view controller’s tab bar item

UIImage* anImage = [UIImage imageNamed:@"MyViewControllerImage.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Home" image:anImage tag:0];

 

8. You can associate tab bar items with your view controllers at any time before displaying your tab bar interface. You do this by assigning the tab bar item to the tabBarItem property of the corresponding view controller.