一、典型多视图应用
1、TAB BAR。
2、NAVIGATION BAR
3、TAB+NAVIGATION
4、TOOL BAR
二、新建一个多视图APP
1、APP效果演示
2、项目结构
// // BIDSwitchViewController.m // View Switcher // // Created by jason on 14-7-17. // Copyright (c) 2014年 jason. All rights reserved. // #import "BIDSwitchViewController.h" @interface BIDSwitchViewController () @end @implementation BIDSwitchViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.blueViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Blue"]; [self.view insertSubview:self.blueViewController.view atIndex:0]; } - (void)didReceiveMemoryWarning { // 回收两个子视图 [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. if (!self.blueViewController.view.superview) { self.blueViewController = nil; }else{ self.yellowViewController = nil; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ //切换逻辑、切换动画 -(IBAction)switchViews:(id)sender { [UIView beginAnimations:@"View Flip" context:NULL]; [UIView setAnimationDuration:0.4]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; if (!self.yellowViewController.view.superview) { if (!self.yellowViewController) { self.yellowViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Yellow"]; } [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; [self.blueViewController.view removeFromSuperview]; [self.view insertSubview:self.yellowViewController.view atIndex:0]; }else{ if (!self.blueViewController) { self.blueViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Blue"]; } [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; [self.yellowViewController.view removeFromSuperview]; [self.view insertSubview:self.blueViewController.view atIndex:0]; } [UIView commitAnimations]; } @end
3、代码下载:
https://github.com/Simba-Hu/View-Switcher.git
git@github.com:Simba-Hu/View-Switcher.git
三、小结
View Controller
Storyboard
UIViewController
Empty Application
Toolbar
the object attributes inspector
control-drag
App Delegate
Show Quick Help Inspector
lazy loading,
superview
Content Views
Main.storyboard
Interface Builder
the object library
scene
Editor - Align- Horizontal Center inContainer
Editor- Align- VerticalCenter in Container
the connections inspector
Touch Up Insideevent
File’sOwnericon
background
the attributes inspector
the identity inspector
the color picker
constraints
Transition
【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications