要求:通过tabbarcontroller实现一个底部导航,并且实现两个界面之间通过button切换,互相传值
参考博客
转
tabbar部分
AppDelegate.m
#import "AppDelegate.h"
#import "ViewControl1.h"
#import "ViewController2.h"
#import "ViewController3.h"
#import "ViewController4.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//创建windows
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.backgroundColor = [UIColor whiteColor];
//初始化一个tabbarcontroller
UITabBarController * bottomTabbarController = [[UITabBarController alloc ]init];
self.window.rootViewController = bottomTabbarController ;
//创建4个子控制器
ViewControl1 * view1 = [[ViewControl1 alloc]init];
view1.tabBarItem.title = @"view1";
ViewController2* view2 = [[ViewController2 alloc]init];
view2.tabBarItem.title = @"view2";
ViewController3 * view3 = [[ViewController3 alloc]init];
view3.tabBarItem.title = @"view3";
ViewController4 * view4 = [[ViewController4 alloc]init];
view4.tabBarItem.title = @"view4";
//添加子类控制器
bottomTabbarController.viewControllers = @[view1,view2,view3,view4];
//显示windows为主窗口
[self.window makeKeyAndVisible] ;
return YES;
}
- (