AppDelegate.m手动添加NavigationController和TabBarController

纯代码编写APP时在AppDelegate.m里面添加NavigationController和TabBarController的代码如下图:

详细代码如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

_window = window;

_window.backgroundColor = [UIColor whiteColor];

_window.hidden = 0;

QYNewsViewController *firstVC = [[QYNewsViewController alloc] init];

UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstVC];

QYReaderViewController *secondVC = [[QYReaderViewController alloc] init];

UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:secondVC];

QYVideoViewController *thirdVC = [[QYVideoViewController alloc] init];

UINavigationController *thirdNav = [[UINavigationController alloc] initWithRootViewController:thirdVC];

QYDiscoverViewController *forthVC = [[QYDiscoverViewController alloc] init];

UINavigationController *forthNav = [[UINavigationController alloc] initWithRootViewController:forthVC];

QYMeViewController *fifthVC = [[QYMeViewController alloc] init];

UINavigationController *fifthNav = [[UINavigationController alloc] initWithRootViewController:fifthVC];

NSArray *viewControllers = @[firstNav,secondNav,thirdNav,forthNav,fifthNav];

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

mainViewController.viewControllers = viewControllers;

mainViewController.tabBar.tintColor = [UIColor colorWithRed:94/255.0 green:211/255.0 blue:44/255.0 alpha:1.0];

_window.rootViewController = mainViewController;

return YES;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,515评论 1 14
  • 废话不多说,直接上干货 ---------------------------------------------...
    小小赵纸农阅读 3,410评论 0 15
  • 代码创建UIWindow对象 Xcode7之后使用代码创建UIWindow对象: //创建UIWindow对象 s...
    云之君兮鹏阅读 1,348评论 0 2
  • 哦吼吼,又研究了几天,把FMDB这个封装好的数据库搞定了,写了个简单的例子,基于FMDB的添删改查操作,界面很一般...
    lichengjin阅读 545评论 0 0
  • 我在外省上小学四年级的时候,曾迷恋过一包产自家乡的碧螺春。 虽说器具简单到就是一个普通的玻璃杯吧,但也极具兴致地模...
    张文山阅读 431评论 4 7