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这个方法的,正 ...
随机推荐
- 使用qt制作简单的加法,乘法运算。
1.首先构架qt应用项目 2.然后打开使用 Qt desinger打开 Fomr File 里的UI文件进行编辑 3.由于此程序只需点击加号,减号这两个按钮,所以设置了两个信号槽 4.然后是连接信号槽 ...
- HDOJ(1000) A + B Problem
代码如下: #include <stdio.h> int main(void) { int a, b; ){ printf("%d\n", a+b); } ; }
- linux系统 备份与还原
linux 系统备份与还原备份系统:1.成为 root 用户: su root2.进入根目录: cd /3.用tar命令打包压缩:tar cvpjf 压缩包名.tar.bz2 --exclude=/压 ...
- LBS地理位置距离计算方法之geohash算法
随着移动终端的普及,很多应用都基于LBS功能,附近的某某(餐馆.银行.妹纸等等).基础数据中,一般保存了目标位置的经纬度:利用用户提供的经纬度,进行对比,从而获得是否在附近.这里需要在设置出一个字段, ...
- mysql 数据库备份,恢复。。。。
mysql 数据备份,恢复,恢复没写,这里只写了备份... 先暂作记录吧! 备份:表结构和数据完全分开,默认有一个文件会记录所有表的结构,然后表中数据的备份 如果超过分卷的大小则会分成多个文件,不然则 ...
- python27读书笔记0.2
# -*- coding:utf-8 -*- ##s.partition(d)##Searches string s for the first occurrence of some delimite ...
- hdu5548
2015ACM/ICPC亚洲区上海站LCM WALK 题意:定义了一种走法,就是从当前的点为sx,sy,可以走到ex,ey;并且ex = sx + z,或者 ey = sy + z, 其中z为lcm( ...
- cocos2dx Tab选项卡控件的实现
选项卡控件在游戏和应用中很是常见,但是cocostudio里并没有实现好的选项卡控件,于是自己封装了 一个,效果如下: 代码: TabUiControl.h #pragma once //std #i ...
- Mongodb FAQ 存储(storage)篇
1.什么是内存映射文件(memory mapped files)? 内存映射文件是操作系统通过调用函数mmap()创建的一个放在内存中的一个数据文件.这种文件可以当做一个从零开始的内存或者数组,你可以 ...
- 关于c++字符串的while(*temp++)
首先,上一段代码 static bool reverse_str(const char *str) { const char *temp=str; while(*temp++); temp-=; // ...