首页 > 其他 > 详细

项目架构(结构)搭建:主流结构(UITabBarController + 导航控制器)

时间:2017-02-25 00:55:50      阅读:216      评论:0      收藏:0      [点我收藏+]
/*
    项目架构(结构)搭建:主流结构(UITabBarController + 导航控制器)
    -> 项目开发方式 1.storyboard 2.纯代码
 */
@interface AppDelegate ()

@end

@implementation AppDelegate

// 程序启动的时候就会调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // 1.创建窗口
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // 2.设置窗口根控制器
    UITabBarController *tabBarVc = [[UITabBarController alloc] init];
    self.window.rootViewController = tabBarVc;
    
    // 2.1 添加子控制器(5个子控制器) -> 自定义控制器 -> 划分项目文件结构
    // 精华
    XMGEssenceViewController *essenceVc = [[XMGEssenceViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:essenceVc];
    // initWithRootViewController:push
    
    // tabBarVc:会把第0个子控制器的view添加去
    [tabBarVc addChildViewController:nav];
    
    // 新帖
    XMGNewViewController *newVc = [[XMGNewViewController alloc] init];
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:newVc];
    // tabBarVc:会把第0个子控制器的view添加去
    [tabBarVc addChildViewController:nav1];
    
    // 发布
    XMGPublishViewController *publishVc = [[XMGPublishViewController alloc] init];
    // tabBarVc:会把第0个子控制器的view添加去
    [tabBarVc addChildViewController:publishVc];
    
    // 关注
    XMGFriendTrendViewController *ftVc = [[XMGFriendTrendViewController alloc] init];
    UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:ftVc];
    // initWithRootViewController:push
    
    // tabBarVc:会把第0个子控制器的view添加去
    [tabBarVc addChildViewController:nav3];
    
    //
    XMGMeViewController *meVc = [[XMGMeViewController alloc] init];
    UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:meVc];
    // initWithRootViewController:push
    
    // tabBarVc:会把第0个子控制器的view添加去
    [tabBarVc addChildViewController:nav4];
    
    // 3.显示窗口 1.成为UIApplication主窗口 2.
    [self.window makeKeyAndVisible];


    return YES;
}

 

项目架构(结构)搭建:主流结构(UITabBarController + 导航控制器)

原文:http://www.cnblogs.com/xufengyuan/p/6440733.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!