【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications

一、典型多视图应用


1、TAB BAR。

【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications


【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications




2、NAVIGATION BAR

【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications





3、TAB+NAVIGATION


【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications



4、TOOL BAR


【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications


二、新建一个多视图APP


1、APP效果演示


【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications


2、项目结构


【 Beginning iOS 7 Development《精通iOS7开发》】06 Multiview Applications



//
//  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

上一篇:Android中 dp 与 px 单位转换


下一篇:IOS使用Jenkins进行持续集成