http://www.cnblogs.com/zengyou/p/3386605.html

//在parent view controller 中添加 child view controller
   FirstViewController *firstViewController=[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self addChildViewController:firstViewController];

SecondViewController *secondViewController=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self addChildViewController:secondViewController];

ThirdViewController *thirdViewController=[[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
[self addChildViewController:thirdViewController];

[self.view addSubview:thirdViewController.view];

  // addChildViewController回调用[child willMoveToParentViewController:self] ,但是不会调用didMoveToParentViewController,所以需要显示调用
[thirdViewController didMoveToParentViewController:self];
currentViewController=thirdViewController;

  //切换child view controller
[self transitionFromViewController:currentViewController toViewController:firstViewController duration:4 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
} completion:^(BOOL finished) {
//......
}];
currentViewController=firstViewController;

  //移除child view controller
// removeFromParentViewController在移除child前不会调用[self willMoveToParentViewController:nil] ,所以需要显示调用
[currentViewController willMoveToParentViewController:nil];
[currentViewController removeFromSuperview];
[currentViewController removeFromParentViewController];

addChildViewController的更多相关文章

  1. addChildViewController后开启热点/wifi/打电话引起的子vc的布局问题

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #00b1ff } p.p2 { margin: 0.0px 0. ...

  2. UIViewController中addChildViewController的作用

    当在一个ViewController中添加一个子ViewController时,UI部分可以直接通过addSubView的方法添加,例如: 在一个ViewControllerA中添加ViewContr ...

  3. iOS 容器 addChildViewController

    //在parent view controller 中添加 child view controller FirstViewController *firstViewController=[[First ...

  4. addChildViewController相关api深入剖析

    注:本文根据个人的实践和理解写成,若有不当之处欢迎斧正和探讨! addChildViewController是一个从iOS5开始支持的api接口,相关的一系列的接口是用来处理viewcontrolle ...

  5. UIViewController添加子控制器(addChildViewController)

    // //  TaskHallViewController.m //  yybjproject // //  Created by bingjun on 15/10/27. //  Copyright ...

  6. IOS笔记 : addChildViewController

    一下addChildViewController,一个ViewController可以添加多个子ViewController,但是这 些子ViewController只有一个是显示到父视图中的,可以通 ...

  7. addChildViewController 与 addSubview

    在viewcontrollerA中, 如果想把controllerB.view添加进来, 可以用 addSubview, 但如果controllerB中有个事件, 使用到 self.navigatio ...

  8. 【转】 iOS开发 剖析网易新闻标签栏视图切换(addChildViewController属性介绍)

    原文:http://blog.csdn.net/hmt20130412/article/details/34523235 本来只是打算介绍一下addChildViewController这个方法的,正 ...

  9. addChildViewController 用法

    // // SCMyOrderViewController.m // SmartCommunity // // Created by chenhuan on 15/9/7. // Copyright ...

随机推荐

  1. 定义函数def

  2. jQuery DOM

    请尊重知识,请尊重原创 更多资料参考请见  http://www.cezuwang.com/listFilm?page=1&areaId=906&filmTypeId=1  jQuer ...

  3. 养成好的JAVA编码习惯

    原文:http://blog.csdn.net/lifuxiangcaohui/article/details/25231027 最近的机器内存又爆满了,除了新增机器内存外,还应该好好review一下 ...

  4. Mvc4_ActionLink跟@RenderBody ,@RenderPage

    . @Html.ActionLink("该链接要显示的文字A","对应的控制器方法B");会生成:<a href="C/B">A ...

  5. iOS开发 创建单例模式

    + (id)defaultNSObjectName { static id defaultNSObjectName = nil; static BOOL token = NO; if (!token) ...

  6. easyui combobox 智能提示搜索

    <!-- 获取机会点名称列表 --><script> function initOpportunityNameFuzzyQuery() { $('#jihuidianmingc ...

  7. 安卓虚拟机启动失败intel haxm未安装

    1:环境是android studio 在AVD中启动显示,提示当前电脑为安装HAXM emulator: ERROR: x86 emulation currently requires hardwa ...

  8. 双心ping GUI工具1.0

    双心ping GUI工具1.0该软件利用WindowsAPI提供了图形界面的ping程序,同时还可以调用DOS下的ping命令.ping成功后自动加入网址列表框及同目录下的列表文件Pinglist.i ...

  9. js代码如何测试代码运行时间

    function add(){ //这里放要执行的代码 } //开始测试并输出 function test() { var start=new Date().getTime(); add(); var ...

  10. 【NOIP2015】推销员

    推(chuan)销员 分析 这里主要阐述一下我的分析思路. 看起来挺直观的. 最初的想法,我们枚举每一个最远点mxp的位置,然后对之前的a进行排序. 那么以mxp为最远点,选x个的最大疲劳值为: 这样 ...