IOS Study Notes-tab bar)

Source: Internet
Author: User
Tags custom name

Create a Root View Controller and inherit from the UITabBarController class. Create other view controllers as sub-views of TabBar and store them in arrays.

Override-(void) viewDidLoad method:

-(Void) viewDidLoad {[super viewDidLoad]; // create a view object as the subview LinFirstViewController * pFirstVC = [[LinFirstViewController alloc] initWithNibName: nil bundle: nil] of the TabBar; linSecondViewController * implements condvc = [[LinSecondViewController alloc] initWithNibName: nil bundle: nil]; // stores view objects in arrays to viewControllers self. viewControllers = [NSArray arrayWithObjects: pFirstVC, export condvc, nil]; // release the created object [pFirstVC release]; [Export condvc release];}


In the sub-view. m file, add the code in the-(id) initWithNibName :( NSString *) nibNameOrNil bundle :( NSBundle *) nibBundleOrNil method to set relevant attributes for the TabBar.

// Set the built-in system flag for tabBar, select it in UITabBarSystemItem, and set the label self. tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemFavorites tag: 111]; // set the custom name and image for the tabBar. The image can be empty. tabBarItem = [[UITabBarItem alloc] initWithTitle: @ "Second" image: nil tag: 112]; // you can specify the number of display information self. tabBarItem. badgeValue = @ "1 ";


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.