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

相關文章
相關標籤/搜索