新建一个空的project;

1.选择File — New — New File,在弹出的窗口,左边选择Cocoa Touch,右边选择UIViewController subclass,之后选Next,在弹出的窗口中,输入名称BlueViewController,并选中With xib,如下图

2.

创建TabBarController.xib:

选择File — New — New File,在弹出的窗口,左边选择User Interface,右边选择Empty:

3.在TabBarController.xib:中拖动Tab Bar Controller 控件到TabBarController.xib中去;

4.在TabBarController.xib中 ;选择File’s Owner,打开Identity Inspector,在Class一栏选择AppDelegate:

如图:

5.在打开Assistant Editor,保证Assistant Editor中打开的是DebbieAppDelegate.h,在左边选中Tab Bar Controller,按住Control,往DebbieAppDelegate.h

中创建映射:

如图:

6.在

DebbieAppDelegate.m中的didFinishLaunchingWithOptions方法中添加代码

- (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 addSubview:self.rootController.view];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

7.单击TabBarController.xib,拖三个个Tab Bar Item到Tab Bar上:

8.选中第一个View Controller,在右边打开Identity Inspector,在Class中选择BlueViewController:

具体看这个:

http://www.howzhi.com/group/iosDevelop/discuss/1936

posted on 2014-12-24 19:21  ทดสอบ  阅读(156)  评论(0)    收藏  举报