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. (十)Linux内核中的常用宏container_of

    Container_of在Linux内核中是一个常用的宏,用于从包含在某个结构中的指针获得结构本身的指针,通俗地讲就是通过结构体变量中某个成员的首地址进而获得整个结构体变量的首地址. Containe ...

  2. J2EE 第二阶段项目之编写代码(六)

    三张表的增 修改 查看.明天可以完成. 周末继续统计.

  3. drupal里面的ajax最粗浅的理解-流程

    1,  form里面的ajax所在地表单元素有一个事件,激发system/ajax,相应的有ajax_form_callback(), 会把被改变的元素值传到form_state[values]中, ...

  4. Android 为PopupWindow设置动画效果

    首先定义显示效果的动画文件: <?xml version="1.0" encoding="utf-8"?> <set xmlns:androi ...

  5. 各种U启网启什么的都是浮云

    对于支持BIOS的电脑,优盘启动,网络启动的各种方案感觉都是浮云,从硬盘启动PE进行维护才是最可靠的.不点在开发wee的过程中给了我们很多维护的灵感,不用费劲地折腾fbinst/U+/量产/PXE/I ...

  6. SAP MM模块之批次管理

    1.Batch的定义:Batch is a quantity any drug produced during a given cycle of manufacture. The essence of ...

  7. 原生js基础问题的一些备忘

    1.在原生js里面  window.onload=function(){}  这个就相当于jquery中 $(document).ready(function(){}); 这样 2.getElemen ...

  8. 怎么在Form1调用Form2中的成员?

    第一种情况,form1和form2有关系,也就可以说成是form1里面有个事件,通过这个事件来打开form2在这个情况下这么写form2 f2 = new form2(这里写form1中的变量值)f2 ...

  9. 浅谈AsyncState与AsyncDelegate使用的异同

    对于AsyncState来说,其MSDN的解释为:得到BeginInvoke方法的最后一个参数.而对于AsyncDelegate来说,其MSDN的解释为:得到异步调用的委托对象.也就是异步调用的委托源 ...

  10. 《Java程序设计》 实验一 实验报告

    实验一 Java开发环境的熟悉(Windows + IDEA) 实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用Eclipse 编辑.编译.运行.调试Java程序. 实验要求 1.完成 ...