- (void)replaceViewController:(UIViewController *)existingViewController withViewController:(UIViewController *)newViewController inContainerView:(UIView *)containerView completion:(void (^)(void))completion
{
// Add initial view controller
if (!existingViewController && newViewController) {
[newViewController willMoveToParentViewController:self];
[newViewController beginAppearanceTransition:YES animated:NO];
[self addChildViewController:newViewController];
newViewController.view.frame = containerView.bounds;
[containerView addSubview:newViewController.view];
[newViewController didMoveToParentViewController:self];
[newViewController endAppearanceTransition];
if (completion) completion();
}
// Remove existing view controller
else if (existingViewController && !newViewController) {
[existingViewController willMoveToParentViewController:nil];
[existingViewController beginAppearanceTransition:NO animated:NO];
[existingViewController.view removeFromSuperview];
[existingViewController removeFromParentViewController];
[existingViewController didMoveToParentViewController:nil];
[existingViewController endAppearanceTransition];
if (completion) completion();
}
// Replace existing view controller with new view controller
else if ((existingViewController != newViewController) && newViewController) {
[newViewController willMoveToParentViewController:self];
[existingViewController willMoveToParentViewController:nil];
[existingViewController beginAppearanceTransition:NO animated:NO];
[existingViewController.view removeFromSuperview];
[existingViewController removeFromParentViewController];
[existingViewController didMoveToParentViewController:nil];
[existingViewController endAppearanceTransition];
[newViewController beginAppearanceTransition:YES animated:NO];
newViewController.view.frame = containerView.bounds;
[self addChildViewController:newViewController];
[containerView addSubview:newViewController.view];
[newViewController didMoveToParentViewController:self];
[newViewController endAppearanceTransition];
if (completion) completion();
}
}

ios containerViewController的更多相关文章

  1. iOS 生命周期

       应用生命周期 App启动:当App启动时,首先由not running状态切换到inactive状态,此时调用application:didFinishLaunchingWithOptions: ...

  2. 自定义视图控制器切换(iOS)

    在iOS开发过程中,通常我们会使用UINavigationController,UITabbarController等苹果提供的视图控制器来切换我们的视图.在iOS5之前,如果要自定义容器视图控制器很 ...

  3. iOS开发无第三方控件的援助达到的效果侧边栏

    最近的研究iOS程序侧边栏.渐渐的发现iOS该方案还开始采取风侧边栏格该,QQ,今日头条,Path(Path运营商最早的侧边栏app该,效果说成是Path效果),所以就研究了下. 然后发现Git Hu ...

  4. 一步步构建iOS路由

    什么是移动端路由层: 路由层的概念在服务端是指url请求的分层解析,将一个请求分发到对应的应用处理程序.移动端的路由层指的是将诸如App内页面访问.H5与App访问的访问请求和App间的访问请求,进行 ...

  5. 分享一下自己ios开发笔记

    // ********************** 推断数组元素是否为空 ********************** NSString *element = [array objectAtIndex ...

  6. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  7. 【疯狂造轮子-iOS】JSON转Model系列之二

    [疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...

  8. 【疯狂造轮子-iOS】JSON转Model系列之一

    [疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...

  9. iOS总结_UI层自我复习总结

    UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...

随机推荐

  1. 【Zend Studio】10.6.0版本设置默认编码为UTF-8

    1.打开Windows->Prefefences 2.找到Workspace->Text file encoding,修改为UTF-8,OK保存.

  2. seeting菜单界面形成--优化

    本文是上一篇文章的优化版: 上文链接地址:http://www.cnblogs.com/zzw1994/p/5016864.html 上文中有很多方法都是过时,并且效率不是很高,主要对JAVA代码进行 ...

  3. 表格控件表头栏目(Column)与数据表头步

    不用手工增加栏目的列,也就是Column,由数据库的查询结果自动创建. 用的是Delphi2010,安装了Dev,用CxGrid显示数据库查询结果.用什么控件没有关键,道理相同的.

  4. 开机一会,出现长时间闪屏,并且跳出SendRpt error

    通过谷歌,发现任务管理器中的Report sending utility 是属于TortoiseSVN 的,所以卸载svn ,然后重启就ok了

  5. 使用WIF实现单点登录Part II —— Windows Identity Foundation基本原理

    在上一篇文章中,我们已经使用WIF构建了一个基于MVC4的简单的身份验证程序,在这篇文章里,我们将探讨一下到底什么是WIF,以及它的工作原理.然后在下一篇文章开始,我们将实际操作,实现单点登录功能. ...

  6. 窗体皮肤实现 - 在VC中简单实现绘制(五)

    到第四部分Delphi XE3的代码能基本完成窗体界面的绘制.窗口中的其他控件的处理方法也是相同的,截获消息处理消息. 问题这个编译出来的个头可不小.Release版本竟然2.43M,完全是个胖子.系 ...

  7. DB2批处理数据导入

    这里需要两个BAT文件 first.bat @echo off @set /p databaseName=1)请输入数据库名: @set /p userName=2)请输入用户名: @set /p u ...

  8. oh-my-zsh配置你的zsh提高shell逼格终极选择

    抱歉,这篇博文推迟发布了,人都是有惰性的...看在这个牛逼闪闪的标题就原谅我吧! 为何这篇文章要归类到 mac 下? 第一个问题,稍后我们说明下. zsh是个什么东东? 第二个问题... 你应该稍微接 ...

  9. hdu 5264 pog loves szh I

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5264 pog loves szh I Description Pog has lots of stri ...

  10. hdu 1113 Word Amalgamation

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 字符串简单题: stl水过 如下: #include<algorithm> #inc ...