打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
纯代码搭建IOS主流框架
1、WYYNavigationController
#import "WYYNavigationController.h"
@implementation WYYNavigationController
-(void)viewDidLoad{
[super viewDidLoad];
}
-(void)didReceiveMemoryWarning{
[self didReceiveMemoryWarning];
}
@end
2、WYYTabBarController
//
//  WYYTabBarController.m
//  test1
//
//  Created by chengyou on 16/1/18.
//  Copyright ? 2016年 wuyingying. All rights reserved.
//
#import "WYYTabBarController.h"
@implementation WYYTabBarController
-(void)viewDidLoad{
[super viewDidLoad];
[self setUpAllChildViewController];
}
-(void) setUpAllChildViewController{
//1.添加第一个控制器
WYYOneViewController *oneVc = [[WYYOneViewController alloc] init];
[self setUpAllChildViewController:oneVc image:[UIImage imageNamed:@"tab_home_icon"] title:@"首页"];
//2.添加第二个控制器
WYYTwoTableViewController *twoVc = [[WYYTwoTableViewController alloc] init];
[self setUpAllChildViewController:twoVc image:[UIImage imageNamed:@"js"] title:@"通讯录"];
//3.添加第三个控制器
WYYThreeTableViewController *threeVc = [[WYYThreeTableViewController alloc] init];
[self setUpAllChildViewController:threeVc image:[UIImage imageNamed:@"qw"] title:@"办公"];
//4.1加载storyboard,这里仅仅是加载名称为WYYFourViewController的storyBoard,并不会创建storyBoard中的控制器和空间
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"WYYFourViewController" bundle:nil];
//4.2创建storyBoard中箭头指向的控制器(初始控制器)
WYYFourViewController *fourVc = [storyBoard instantiateInitialViewController];
//4.3添加第四个控制器
[self setUpAllChildViewController:fourVc image:[UIImage imageNamed:@"user"] title:@"设置"];
}
#pragma mark -- 添加一个子控制器的方法
-(void)setUpAllChildViewController:(UIViewController *)viewController image:(UIImage *)image title:(NSString *)title{
UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:viewController];
navC.title = title;
navC.tabBarItem.image = image;
[navC.navigationBar setBackgroundImage:[UIImage imageNamed:@"commentary_num_bg"] forBarMetrics:UIBarMetricsDefault];
viewController.navigationItem.title = title;
[self addChildViewController:navC];
}
@end
3、WYYViewController
//
//  WYYViewController.m
//  test1
//
//  Created by chengyou on 16/1/18.
//  Copyright ? 2016年 wuyingying. All rights reserved.
//
#import "WYYViewController.h"
@implementation WYYViewController
-(void)viewDidLoad{
//如果控制器A的View成为控制器B的View的子控件,那么A控制器成为B控制器的子控制器
WYYTabBarController *tabBarVc = [[WYYTabBarController alloc] init];
//添加WYYTabBarController为子控制器
[self addChildViewController:tabBarVc];
}
@end
4、AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//1.创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
//2.设置窗口的根控制器
WYYTabBarController *dragVc = [[WYYTabBarController alloc] init];
self.window.rootViewController = dragVc;
//3.显示窗口
[self.window makeKeyAndVisible];
return YES;
}
5、配置Main Interface
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
3、show—UIWindow简单介绍
ios视频播放器,代码和界面分离
百思不得姐框架分析(一)
UITabBarController
新浪微博整理
iOS开发经验总结(下)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服