addChildViewController 与 addSubview
在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的更多相关文章
- iOS开发 关于addChildViewController的理解
iOS开发 关于addChildViewController的理解 前言 我之前是做Android开发的接触ios开发不到一个月的时间,所以在有些东理解上会不自觉的向Android方向靠拢. 理解 通 ...
- 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. ...
- UIViewController中addChildViewController的作用
当在一个ViewController中添加一个子ViewController时,UI部分可以直接通过addSubView的方法添加,例如: 在一个ViewControllerA中添加ViewContr ...
- iOS 容器 addChildViewController
//在parent view controller 中添加 child view controller FirstViewController *firstViewController=[[First ...
- addChildViewController相关api深入剖析
注:本文根据个人的实践和理解写成,若有不当之处欢迎斧正和探讨! addChildViewController是一个从iOS5开始支持的api接口,相关的一系列的接口是用来处理viewcontrolle ...
- addChildViewController
http://www.cnblogs.com/zengyou/p/3386605.html //在parent view controller 中添加 child view controller Fi ...
- UIViewController添加子控制器(addChildViewController)
// // TaskHallViewController.m // yybjproject // // Created by bingjun on 15/10/27. // Copyright ...
- IOS笔记 : addChildViewController
一下addChildViewController,一个ViewController可以添加多个子ViewController,但是这 些子ViewController只有一个是显示到父视图中的,可以通 ...
- 【转】 iOS开发 剖析网易新闻标签栏视图切换(addChildViewController属性介绍)
原文:http://blog.csdn.net/hmt20130412/article/details/34523235 本来只是打算介绍一下addChildViewController这个方法的,正 ...
随机推荐
- 九度OJ 1514 数值的整数次方【算法】
题目地址:http://ac.jobdu.com/problem.php?pid=1514 题目描述: 给定一个double类型的浮点数base和int类型的整数exponent.求base的expo ...
- dd命令测试linux磁盘读写速度
1.先熟悉两个特殊的设备: (1)/dev/null:回收站.无底洞. (2)/dev/zero:产生字符. 2.测试磁盘写能力 time dd if=/dev/zero of=/t ...
- C#基础(三)—重载与覆盖
所谓重载指的是同一个类中有两个或多个名字相同但是参数不同的方法.重载,必然发生在一个类中,函数名相同,参数类型或者顺序不同构成重载,与返回类型无关. override:过载也称重写是指子类对父类中虚函 ...
- 网页frame引入实现全屏滚动,使用jquery实现浏览器兼容
近期做一个项目,其中有一个需求,就是网页中需要用frame引入页面并实现frame的全屏,在网上查了好多感觉方式都不尽相同,但是都不是介绍的很全面,浏览器的兼容也做的不好,自己总结了一些要点,需要的可 ...
- Spring 官方下载地址(非Maven)
现在spring的官网停止了使用zip包下载,只能使用maven,非常的不方便,分享如下网址可以使用zip包下载,是不是方便多了!~ 下载列表如下: spring-framework-3.2.8.RE ...
- dataTable 禁止排序
$("#id").DataTable({ "ordering": false, // 禁止排序 });
- noj [1475] Bachelor (找1的个数)
http://ac.nbutoj.com/Problem/view.xhtml?id=1475 [1475] Bachelor 时间限制: 1000 ms 内存限制: 65535 K 问题描述 炎热的 ...
- ASP.NET异常:找到多个具有相同ID"xxx"的控件。FindControl要求控件具有唯一的ID
出错场景是这样使用的: 1.FindControl遍历Page.Form.Controls,将其放到一个List里. 2.Page.Form.Controls.Clear(),清空所有控件 3.往Pa ...
- MongoDB索引介绍
MongoDB中的索引其实类似于关系型数据库,都是为了提高查询和排序的效率的,并且实现原理也基本一致.由于集合中的键(字段)可以是普通数据类型,也可以是子文档.MongoDB可以在各种类型的键上创建索 ...
- java Arrays.asList()和Collections.addAll()
java中的方法Arrays.asList(arg1,arg2,arg3...),经常用在将多个元素或数组转化为List中的元素,但是在使用的时候,应该注意: arg1决定返回list的元素类型(即第 ...