一下addChildViewController,一个ViewController可以添加多个子ViewController,但是这 些子ViewController只有一个是显示到父视图中的,可以通过transitionFromViewController:toViewController:duration:options:animations:completion:这个方法转换显示的子视图。同时加入相应的动画。

 //在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];

  

IOS笔记 : addChildViewController的更多相关文章

  1. 荼菜的iOS笔记--UIView的几个Block动画

    前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...

  2. IOS笔记 1

    < ![CDATA[ 笔记 UIWindows 与UIView的关系iOS的坐标系统视图层次结构视图坐标(Frame和Bounds区别)UIView的常用属性和方法坐标系统的变换UIView内容 ...

  3. 【转】iOS笔记-自定义控件(OC)

    原文网址:http://www.jianshu.com/p/f23862eb7b8a 导读: iOS开发中,很多时候系统提供的控件并不能很好的满足我们的需求,因此,自定义控件便成为搭建UI界面中必不可 ...

  4. View Controller Programming Guid for iOS 笔记

    1.View Controller 基础 1.1 View Controller 分类 ViewController分为container view controller 和content view ...

  5. iOS笔记———数据存储

    应用沙盒:应用文件系统的根目录,每个应用都有独自的沙盒相互:在xcode中可以用NSHomeDirectory()函数,打印当前应用的沙盒根路径. 应用程序包:包含了所有资源文件和执行文件; * Do ...

  6. Xamarin开发IOS笔记:切换输入法时输入框被遮住

    在进行IOS开发的过程中,出现类似微信朋友圈的交互界面,当用户遇到感兴趣的内容可以进行评论.为了方便评论输入,当出现评论输入框的时候自动将评论输入框移动至键盘的上方,这样方便边输入边查看. 当用户隐藏 ...

  7. iOS 容器 addChildViewController

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

  8. 【IOS笔记】Delegation

    Delegation Delegation is a simple and powerful pattern in which one object in a program acts on beha ...

  9. 【IOS笔记】Event Delivery: The Responder Chain

    Event Delivery: The Responder Chain  事件分发--响应链 When you design your app, it’s likely that you want t ...

随机推荐

  1. 洗清UI自动化鸡肋说的不白之冤

    人类文明发展的一个重要标识是工具的诞生,当人类开始制作工具来提高生产力时,就逐渐拉开了与其他生物的距离.曾在2013年,<Google如何测试软件>中提到的分层自动化金字塔,轰动业界.而在 ...

  2. Linux下程序对拍_C++

    此博客需要付费才阅读,因为该博客实用性十分强,且十分容易理解 若需购买请联系博主,联系方式戳这 http://www.cnblogs.com/hadilo/p/5932395.html 主要介绍如何在 ...

  3. Jsp:useBean标签的使用

    1.<jsp:useBean id="为Bean起的别名(随意起)" class="Bean的目录,从包名开始写" scope="page | ...

  4. DIV CSS布局容易忽略的属性

    white-space:pre //保留空格,不然又多个空格值显示一个 white-space:nowrap //强制不换行,知道遇到</br> letter-spacing //字母间的 ...

  5. 无法完成安装:'unsupported configuration: hda-duplex not supported in this QEMU binary'

    Linux 有问必答:如何修复"hda-duplex not supported in this QEMU binary" 编译自:http://ask.xmodulo.com/h ...

  6. 五、用户数据报传输(UDP)

    1.UDP常用的发送和接收函数 int recvfrom(int sockfd,void *buf,int len,unsigned int flags,struct sockaddr *from,i ...

  7. github的入门使用

    原文 http://www.eoeandroid.com/thread-274556-1-1.html [初识Github]首先让我们大家一起喊一句“Hello Github”.YEAH!就是这样. ...

  8. HttpClient特性

    Http协议的重要性相信不用我多说了,HttpClient相比传统JDK自带的URLConnection,增加了易用性和灵活性(具体区别,日后我们再讨论),它不仅是客户端发送Http请求变得容易,而且 ...

  9. Android IOS WebRTC 音视频开发总结(五五)-- 音视频通讯中的抗丢包与带宽自适应原理

    本文主要分析webrtc中的抗丢包与带宽自适应原理,文章来自博客园RTC.Blacker,欢迎关注微信公众号blacker,更多详见www.rtc.help 文章内容主要来自中国电信北京研究院丁博士在 ...

  10. WireShark 过滤语法

    1. 过滤IP,如来源IP或者目标IP等于某个IP 例子: ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107 或者 ip.addr eq 192.1 ...