A) SETTING UP THE TAB BAR FRAMEWORK
1) Create a New Project. Select Empty Application. Click Next.
1.1) Product Name: Pickers1.
1.2) Use Core Data: No.
1.3) Device Family: iPhone.
1.4) Use Automatic Reference: Yes.
1.5) Create Project Application Folder.
2) Single-Click the Pickers1 folder. Create New File. Select Cocoa Touch, Objective-C Class. Click Next.
2.1) Class Name: DatePickerViewController.
2.2) Subclass Of: UIViewController.
2.3) XIB user interface: Yes.
3.4) Targeted for iPad: No.
2.5) Create in the same Project Application Folder.
2.6) Notice that three files have been created:
- DatePickerViewController.h
- DateViewController.m
- DatePickerViewController.xib
3) Repeat Step No. 2 for:
3.1) SingleComponentPickerViewController
3.2) DoubleComponentPickerViewController
3.3) DependenrComponentPickerViewController
3.4) CustomPickerViewController
4) Check that your final work is as follows:
B) ADDING THE ROOT VIEW CONTROLLER
1) Open AppDelegate.h and edit:
#import <UIKit/UIKit.h>
@interface BIDAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) IBOutlet UITabBarController *rootController;
@end2) Open AppDelegate.m and edit:
#import "BIDAppDelegate.h"
@implementation BIDAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)
launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.[[NSBundle mainBundle] loadNibNamed:@"TabBarController" owner:self options:nil]; self.window.rootViewController = self.rootController; self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
} C) CREATING TabBarController.xib
1) Click Pickers1 folder. Create New File.
1.1) Category: iOS/User Interface.
1.2) Type: Empty template.
1.3) Device Family: iPhone,
1.4) UI Name: TabBarController.
1.5) Create.
D) DESIGNING VIEW
1) Drag Tab Bar Controller from the Object Library to the View Layout.
2) A Tab Bar Controller with a default 2-bar is created.
3) Click File's Owner icon. Go to Identity Inspector. Change NsObject to AppDelegate.
4) Add another Tab Bar Item to the Tab Bar Controller. Repeat for 3 times (Finally you get 5 tabs.)
5) While Tab Bar is selected, go to Show Attributes Inspector. Set NIB Name as DatePickerViewController, i.e linking the Tab Item to the Controller defined in Step 3. Repeat the steps until all Tab Items have been assigned to Controllers.
6) Set Properties for each component.
6.1) Date.
6.2) Single.
6.3) Double.
6.4) Dependent.
6.5) Custom.
7) Compile and run to see the progress so far.
No comments:
Post a Comment