您可以從蘋果的文檔找到更具描述性的例子 - Combined View Controller Interfaces
我假設登錄頁面是你的根視圖控制器在這裏。其中_tabBar
,_window
和_loginvVewController
是在appDelegate頭文件中全局聲明的。根據您的要求,您也可以在didFinishLaunchingWithOptions
方法中本地取_loginvVewController
。
AppDelgate.h
UIWindow *_window;
UITabBarController *_tabBar;
LoginViewController *_loginvVewController;
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.loginvVewController = [[LoginViewController alloc] init];
// Add the tab bar controller's current view as a subview of the window
[self.window addSubview:self.loginvVewController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)initializeTabbar {
/*
* Set up controllers for the tab bar controller
*/
EmployeeViewController *vc1 = [[[EmployeeViewController alloc] initWithTitle:@"View 1"] autorelease];
TaskViewController *vc2 = [[[TaskViewController alloc] initWithTitle:@"View 2"] autorelease];
HomeViewController *vc3 = [[[HomeViewController alloc] initWithTitle:@"View 3"] autorelease];
// View Controller with each Navigational stack support.
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:vc1];
/*
* Set up tab bar controller
*/
self.tabBar = [[UITabBarController alloc] init];
self.tabBar.viewControllers = [NSArray arrayWithObjects:navController, vc2, vc3, nil];
[self.window addSubview:self.tabBar.view];
}
在我的快速編程馬拉松對於這個問題,我已經採取了按鈕 「點擊這裏!」在登錄頁面 - 一旦你點擊它將用tabbar在你的應用程序內導航你。如果您需要示例項目,請發送電子郵件至[email protected]。
經過電子郵件的許多請求 - 我已經創建了演示項目,並在這裏上傳。 https://github.com/Deminem/SimpleTabbarApp--iPhone-
如果你覺得有用請投票。
祝你好運!
創建一個標籤欄控制器和配置它需要比打開了一個全新的項目,並導入所有現有的代碼和重新配置構建設置,等等 – 2011-05-07 10:05:12