您的位置:首页 > 产品设计 > UI/UE

基于代码的 UITabbarController与UINavgationController 实现下导航页面切换

2014-08-07 14:22 609 查看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];

//初始化一个 UITabBarController

UITabBarController *tabbarController=[[UITabBarController alloc]init];

//初始化  UINavigationController,并把UIViewController 设为rootview
ZAFirstViewController *firstVC=[[ZAFirstViewController alloc]init];
firstVC.title=@"1";
UINavigationController *firstNV=[[UINavigationController alloc]initWithRootViewController:firstVC];

ZASecondViewController *secondVC=[[ZASecondViewController alloc]init];
secondVC.title=@"2";
UINavigationController *secondNV=[[UINavigationController alloc]initWithRootViewController:secondVC];

ZAThirdViewController *thirdVC=[[ZAThirdViewController alloc]init];
thirdVC.title=@"2";
UINavigationController *thirdNV=[[UINavigationController alloc]initWithRootViewController:thirdVC];

//设置UITabBarController的viewControllers数组为  UINavigationController 数组
tabbarController.viewControllers=@[firstNV,secondNV,thirdNV];

//将window的rootViewController 设置为 UITabBarController
self.window.rootViewController=tabbarController;

[self.window makeKeyAndVisible];
return YES;
}


效果如图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息