How to Create a Simple Uitabbar in Xcode
A simple demonstration by code on how to implement a UITabBar on iPhone. 1.) Create a new Windows based project, and named it whatever you...
https://www.czetsuyatech.com/2010/12/xcode-uitabbar.html
A simple demonstration by code on how to implement a UITabBar on iPhone.
1.) Create a new Windows based project, and named it whatever you want.
2.) You should look up for 2 files, .h and .m (I named mine MyTab).
MyTabAppDelegate.h
MyTabAppDelegate.m
1.) Create a new Windows based project, and named it whatever you want.
2.) You should look up for 2 files, .h and .m (I named mine MyTab).
MyTabAppDelegate.h
#import <UIKit/UIKit.h> @interface MyTabAppDelegate : NSObject{ UIWindow *window;
UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @end
MyTabAppDelegate.m
#import "MyTabAppDelegate.h" @implementation MyTabAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(UIApplication *)application { //initialize the UITabBarController tabBarController = [[UITabBarController alloc] init]; //Create the first UITabBarItem UIViewController *viewController1 = [[UIViewController alloc] init]; [viewController1 setTitle:@"MyTab1"]; //note that you can set the tab bar item's icon by uncommenting the line below //viewController1.tabBarItem.image = [UIImage imageNamed:@"any image in your resource"]; viewController1.view.backgroundColor = [UIColor orangeColor]; //Create the second UITabBarItem UIViewController *viewController2 = [[UIViewController alloc] init]; [viewController2 setTitle:@"MyTab2"]; viewController2.view.backgroundColor = [UIColor redColor]; //add the UIViewControllers to the UITabController tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil]; //release [viewController1 release]; [viewController2 release]; //add to the main window [window addSubview:tabBarController.view]; // Override point for customization after application launch [window makeKeyAndVisible]; } - (void)dealloc { [window release]; [super dealloc]; } @end
Post a Comment