• 新建3个ViewController的类
  • 新建main.stroyboard,并配置好相应的布局(编辑界面,连接视图与类,ViewController的Storyboard ID,连接3个Button的响应事件)
  • 删除app delegate中didFinishLaunchingWithOptions中的代码
  • 修改SwitchViewController.m代码(viewDidLoad,didReceiveMemoryWarning,switchButton的响应函数(包括动画))
  • 修改BlueViewController.m和YellowViewController.m,添加button响应函数

XYZSwitchViewController.m

//
// XYZSwitchViewController.m
// MultiView
//
// Created by Norcy on 14-7-23.
// Copyright (c) 2014年 QQLive. All rights reserved.
// #import "XYZSwitchViewController.h"
#import "XYZBlueViewController.h"
#import "XYZYellowViewController.h" @interface XYZSwitchViewController ()
@property (strong, nonatomic)XYZBlueViewController *blueViewController;
@property (strong, nonatomic)XYZYellowViewController *yellowViewController;
@end @implementation XYZSwitchViewController - (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:];
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
if (!self.yellowViewController.view.superview)
self.yellowViewController = nil;
else
self.blueViewController = nil;
} - (IBAction)switchViews:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if (!self.yellowViewController.view.superview)
{
if (!self.yellowViewController)
self.yellowViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Yellow"];
[self.blueViewController.view removeFromSuperview];
[self.view insertSubview:self.yellowViewController.view atIndex:];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
}
else
{
if (!self.blueViewController)
self.blueViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Blue"];
[self.yellowViewController.view removeFromSuperview];
[self.view insertSubview:self.blueViewController.view atIndex:];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
}
[UIView commitAnimations];
}
@end

XYZBlueViewController.m

//
// XYZBlueViewController.m
// MultiView
//
// Created by Norcy on 14-7-23.
// Copyright (c) 2014年 QQLive. All rights reserved.
// #import "XYZBlueViewController.h" @interface XYZBlueViewController () @end @implementation XYZBlueViewController - (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.
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (IBAction)blueBtnPressed:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Blue" delegate:self.view cancelButtonTitle:@"Got it" otherButtonTitles:nil]; [alert show];
}
@end

XYZYellowViewController.m同理,所有头文件保持不变。

Multiview的更多相关文章

  1. 多视图学习(multiview learning)

    多视图学习(multi-view learning) 前期吹牛:今天这一章我们就是来吹牛的,刚开始老板在和我说什么叫多视图学习的时候,我的脑海中是这么理解的:我们在欣赏妹子福利照片的时候,不能只看45 ...

  2. ASP.NET服务器控件使用之MultiView和View

    MultiView 控件是一组 View 控件的容器.使用它可定义一组 View 控件,其中每个 View 控件都包含子控件. 用 ActiveViewIndex 属性或SetActiveView 方 ...

  3. 【转】ASP.NET服务器控件使用之MultiView和View

    MultiView 和 View 控件和制作出选项卡的效果,MultiView 控件是一组 View 控件的容器.使用它可定义一组 View 控件,其中每个 View 控件都包含子控件. 如果要切换视 ...

  4. 从零开始学ios开发(十):Multiview Applications(多个xib之前的切换)

    这篇学习的主要内容是Multiview,在我们学习iphone旋转的时候,介绍过多个view的使用方法,不过这里的view和旋转屏幕中所指的多个view是不同的,旋转屏幕中涉及到的多个view是在一个 ...

  5. MultiView空间例子

    CSS代码: body { font-size:11pt; font-family:宋体; } .mainTitle { font-size:11pt; font-weight:bold; font- ...

  6. Multi-View 3D Reconstruction with Geometry and Shading——Part-2

    From PhDTheses Multi-View 3D Reconstruction with Geometry and Shading 我们的主要目标是只利用图像中的信息而没有额外的限制或假设来得 ...

  7. Multi-View 3D Reconstruction with Geometry and Shading——Part-1

    From PhDTheses Multi-View 3D Reconstruction with Geometry and Shading 计算机视觉的主要任务就是利用图像信息能智能理解周围的世界. ...

  8. face detection[Multi-view face detection&& MTCNN]

    因为这两篇论文感觉内容较短,故而合并到一个博文中. Multi-view face detection 本文来自<Multi-view Face Detection Using Deep Con ...

  9. Multi-View Region Adaptive Multi-temporal DMM and RGB Action Recognition

    论文标题:Multi-View Region Adaptive Multi-temporal DMM and RGB Action Recognition 来源/作者机构情况: 解决问题/主要思想贡献 ...

  10. Firemonkey MultiView

    MultiView 做导航用的. http://docwiki.embarcadero.com/RADStudio/Seattle/en/Mobile_Tutorial:_Using_a_MultiV ...

随机推荐

  1. Python将一个大文件按段落分隔为多个小文件的简单方法

    今天帮同学处理一点语料. 语料文件有点大,而且是以连续两个换行符作为段落标志,他想把它按段落分隔成多个小文件.即每3个段落组成一个新文件.因为曾经没有遇到过类似的操作,在网上找了一些类似的方法,看起来 ...

  2. VUE购物车示例

    代码下载地址:https://github.com/MengFangui/VueShoppingCart 1.index.html <!DOCTYPE html> <html lan ...

  3. spring中autowire的用法

    Autowire模式就是在spring的声明文件里用作进行对象间的关联关系自动绑定的,就是在spring beanfactory内的一个bean对其bean的引用可以自动进行,而不一定用ref=的方式 ...

  4. struts2 result type类型

    result标签中type的类型 类型 说明 chain 用于Action链式处理 dispatcher 用于整合JSP,是<result>元素默认的类型 freemarket 用来整合F ...

  5. Leetcode Find Minimum in Rotated Sorted Array 题解

    Leetcode Find Minimum in Rotated Sorted Array 题目大意: 对一个有序数组翻转, 就是随机取前K个数,移动到数组的后面,然后让你找出最小的那个数.注意,K有 ...

  6. css中属性值继承小解

    继承:html元素可以从父元素那里继承一部分css属性,即使当前元素没有定义该属性. 1.css可以和不可以继承的属性 不可继承的:display.margin.border.padding.back ...

  7. pandas所占内存释放

    df = pd.read_csv('....') 要调用循环处理多个文件时,内存占用情况严重,如果互相之间不需要调用,可以直接del df  释放内存

  8. ClientViaBehavior行为

    ClientViaBehavior行为: 紧接红框:方式,也支持配置的应用方式

  9. unity, 不要试图用rigidbody.Sleep()停止rigidbody

    如果想让rigidbody pause,用rigidbody.Sleep()是完全错误的办法.因为有很多情况都可能使一个处在sleep的rigidbody唤醒,所以调用rigidbody.Sleep( ...

  10. MySQL加速查询速度的独门武器:查询缓存

    [导读] 与朋友或同事谈到MySQL查询缓存功能的时候,个人喜欢把查询缓存功能Query Cache比作荔枝, 是非常营养的东西,但是一次性吃太多了,就容易上火而流鼻血,虽然不是特别恰当的比喻,但是有 ...