Use tabbarcontroller for iPhone Development

Source: Internet
Author: User

-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions
{
Self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds];
Self. window. backgroundColor = [UIColor whiteColor];

// Generate various view Controllers
MedicalData * aa = [[MedicalData alloc] init];
HealthRecord * bb = [[HealthRecord alloc] init];
KonwledgeBase * cc = [[KonwledgeBase alloc] init];
Carepretries * dd = [[careprew.alloc] init];
// Add an array
NSArray * controllerArray = [[NSArray alloc] initWithObjects: aa, bb, cc, dd, nil];
// Create a UITabBarController controller (defined in. h. If arc is enabled, the controller is automatically released and memory access error occurs)
TabBarController = [[UITabBarController alloc] init];
// Set Delegation
TabBarController. delegate = self;
// Set the viewControllers attribute of the UITabBarController to the previously generated array controllerArray.
TabBarController. viewControllers = controllerArray;
// By default, 1st view tabs are selected (the index starts from 0)
TabBarController. selectedIndex = 0;
// Set the title and image of TabBarItem
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 0] setTitle: @ "aa"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 0] setImage: [UIImage imageNamed: @ "1517.png"]; // 30*30
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 1] setTitle: @ "bb"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 1] setImage: [UIImage imageNamed: @ "light.png"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 2] setTitle: @ "cc"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 2] setImage: [UIImage imageNamed: @ "podcaste.png"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 3] setTitle: @ "dd"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 3] setImage: [UIImage imageNamed: @ "setting.png"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 4] setTitle: @ "ee"];
[(UITabBarItem *) [tabBarController. tabBar. items objectAtIndex: 4] setImage: [UIImage imageNamed: @ "unlock.png"];
// Read
UIViewController * activeController = tabBarController. selectedViewController;
If (activeController = aa ){
//
}
// Add the view of tabBarController as a subview to the window
[Self. window addSubview: tabBarController. view];
[Self. window makeKeyAndVisible];
Return YES;

}

From fanwa Software

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.