ios TabBarController

 

新建一个空的project;ios

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

2.ide

建立TabBarController.xib:spa

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

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

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

如图:it

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

中建立映射:class

如图:

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

相关文章
相关标签/搜索