您可以从 Apple 文档中找到更多描述性示例 -组合视图控制器接口
我假设登录页面是您的根视图控制器。其中_tabBar
,_window
和_loginvVewController
在 appDelegate 头文件中全局声明。您也可以根据您的要求在_loginvVewController
本地使用该方法。didFinishLaunchingWithOptions
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];
}
在我针对这个问题的快速黑客马拉松中,我选择了“点击这里!”按钮。在登录页面上 - 单击它后,您将使用标签栏在应用程序中导航。如果您需要示例项目,请发送电子邮件至 d3minem@gmail.com。
在通过电子邮件提出许多请求后 - 我创建了演示项目并在此处上传。https://github.com/Deminem/SimpleTabbarApp--iPhone-
如果您觉得有用,请投票。
祝你好运!