在viewcontrollerA中, 如果想把controllerB.view添加进来,

可以用 addSubview, 但如果controllerB中有个事件, 使用到 self.navigationController 来做操作是不行的.

因为 self.navigationController 为空.

这时需要在controllerA中生成controllerB时,添加加一句

[self addChildViewController:controllerB];

        _userSRCtl = [[LatterJoinViewController alloc] init];
_userSRCtl.latterJoinType = LatterJoinTypeSearch;
_userSRCtl.searchKeyStr = _mySearchBar.text;
_userSRCtl.viewHeight = SCREEN_HEIGHT - kStatusbarHeight - kNavbarHeight - 44;
[self addChildViewController:_userSRCtl];
[self.view addSubview:_userSRCtl.view];

  

/*
If the child controller has a different parent controller, it will first be removed from its current parent
by calling removeFromParentViewController. If this method is overridden then the super implementation must
be called.
Adds the specified view controller as a child of the current view controller. The view controller to be added as a child.
*/ - (void)addChildViewController:(UIViewController *)childController NS_AVAILABLE_IOS(5_0);

  

addChildViewController 与 addSubview的更多相关文章

  1. iOS开发 关于addChildViewController的理解

    iOS开发 关于addChildViewController的理解 前言 我之前是做Android开发的接触ios开发不到一个月的时间,所以在有些东理解上会不自觉的向Android方向靠拢. 理解 通 ...

  2. 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. ...

  3. UIViewController中addChildViewController的作用

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

  4. iOS 容器 addChildViewController

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

  5. addChildViewController相关api深入剖析

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

  6. addChildViewController

    http://www.cnblogs.com/zengyou/p/3386605.html //在parent view controller 中添加 child view controller Fi ...

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

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

  8. IOS笔记 : addChildViewController

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

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

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

随机推荐

  1. BootstrapDialog点击空白处禁止关闭

    在乐学一百的项目当中引用到了BootstrapDialog,其中后台发送短信时,为了防止管理员编辑了半天的短息,突然间因为点击某个空白区域导致丢失,所以在此禁用掉点击空白关闭弹出框. 主要属性为: c ...

  2. 《APUE》第四章笔记(2)

    下面介绍对stat结构的各个成员的操作函数. 先贴个stat结构的图: access函数: #include <unistd.h> int access(const char *pathn ...

  3. Blu-Ray BRRip 和 BDRip 的区别

    Blu-Ray BRRip & BDRip 的区别 最近看电影有点多,常常看到blueray或者BDRip的格式,所以找了一下这两种格式的区别. BRRip = 来自蓝光盘片的xvid编码 B ...

  4. C++ union 公共体

    union myun { struct { int x; int y; int z; }u; int k; }a; int main() { a.u.x =; a.u.y =; a.u.z =; a. ...

  5. 一步步学习ASP.NET MVC3 (13)——HTML辅助方法

    请注明转载地址:http://www.cnblogs.com/arhat 今天老魏是在十分郁闷,我的一个U盘丢了,心疼里面的资料啊,全部是老魏辛辛苦苦积攒的Linux资料,太心疼,到现在心情还不是很爽 ...

  6. Oracle目录结构及创建新数据库

    oracle目录结构 当需要创建新的数据仓库时我可以用 Database Configuration Assistant(数据库配置助手) admin 存放创建的不同数据库 cfgtoollogs c ...

  7. 常用javascript代码片段集锦

    常用方法的封装 根据类名获取DOM元素 var $$ = function (className, element) { if (document.getElementsByClassName) { ...

  8. SpringMVC+Hibernate架构save方法事务未提交

    今天同事遇到一个问题,一起研究,最后解决,让我对spring的事务管理又加深了印象. 先简单说一下项目:项目是Spring和Hibernate集成的JavaEE项目,MVC架构. 外包在service ...

  9. jquery delegate

    代码如下:   $('#container').delegate('a','click',function(){alert('That tickles!')} JQuery扫描文档查找$('#cont ...

  10. A Neural Network in 11 lines of Python

    A Neural Network in 11 lines of Python A bare bones neural network implementation to describe the in ...