viewController备注
1、按结构可以对iOS的所有ViewController分成两类:
1)、主要用于展示内容的ViewController,这种ViewController主要用于为用户展示内容,并与用户交互,如UITableViewController,UIViewController。
2)、用于控制和显示其他ViewController的ViewController。这种ViewController一般都是一个 ViewController的容器。如UINavigationController,UITabbarController。它们都有一个属 性:viewControllers。其中UINavigationController表示一种Stack式结构,push一个 ViewController或pop一次,因此后一个ViewController一般会依赖前一个ViewController。而 UITabbarController表示一个Array结构,各个ViewController是并列的。
第一种ViewController会经常被继承,用来显示不同的数据给用户。而第二种很少被继承,除非你真的需要自定义它。
2、当view被添加其他view中之前时,会调用viewWillAppear,而之后会调用viewDidAppear。
当view从其他view中移出之前时,会调用viewWillDisAppear,而之后会调用viewDidDisappear。
当view不在使用,而且是disappeared,受到内存警告时,那么viewController会将view释放并将其指向nil。
3、由于Controller加载View时,会自动将一些View对象指向其对应的IBOutlet变量。
所以当view被卸载时我们必须在viewDidUnload将这些变量release掉,ViewController不会自动做这件事。
具体做法是将变量设置为空,(注意和dealloc中将变量release的区别)注意此时Controller的view属性是空的。
4.popViewControllerAnimated被调用的时候,前一个viewController页面会调用viewWillAppear,而不会调用viewDidload.因为其已经存在于导航栈中:
You don't need to instantiate your first controller in order to pop to it. It already exists.
viewDidLoad will only run when you load the viewController for the first time (i.e. when you push to it). When you push to other controllers they are put onto a stack (imagine a stack of cards). When you push another card onto the stack the cards beneath it are already there.
When you pop it is like removing a card from the stack. But the card underneath is already there so it doesn't need to load again. All it does is run viewWillAppear.
All you need to do to pop back is...
[self.navigationController popViewControllerAnimated:YES];
That's it.
Remove the stuff about NewSongController (if that is what you are trying to go back to).
Then in the NewSongController function - (void)viewWillAppear:animated;
put the code you want to run when you get back to it.
Hope that helps
viewController备注的更多相关文章
- 业务中是否有必要让所有的ViewController统一继承抽象类
疑问来自:这里 1.事出有因 其中博主说道的情况我其实也经历过,当时还在找到一个模式可以改变这样的情况.直到有一天看到这个博客,今天晚上有时间来规整一下博主的思路和写了一个测试代码. 这是我目前的Ap ...
- ViewController详解
一.生命周期 当一个视图控制器被创建,并在屏幕上显示的时候. 代码的执行顺序1. alloc 创建对象,分配空间2.init (initWit ...
- View和viewController的生命周期
View和viewController的生命周期 一.ViewController的职责 对内管理与之关联的View,对外跟其他ViewController通信和协调.对于与之关联的View,View ...
- iOS点滴- ViewController详解
一.生命周期 当一个视图控制器被创建,并在屏幕上显示的时候. 代码的执行顺序 1. alloc 创建对象,分配空间 2.init (initW ...
- iOS view和viewController的生命周期
一.ViewController的职责 对内管理与之关联的View,对外跟其他ViewController通信和协调.对于与之关联的View,ViewController总是在需要的时候才加载视图,并 ...
- DBCP 配置备注
<property name="initialSize" value="5"></property> <property name ...
- JNI 备注
本文记录一个基础的JNI例子及过程中遇到的问题解决. 1.定义一个JAVA类如下: package jnidemo01; public class JniHello { public native v ...
- DoraCMS 源码知识点备注
项目需要研究了下DoraCMS这款开源CMS,真心做的不错:).用的框架是常用的express 4 + mongoose,代码也很规范,值得学习. 源码中一些涉及到的小知识点备注下: https:// ...
- 如何用代码读取Office Online Server2016的文档的备注信息
前言 在一个项目上客户要求读取office online server 2016的对文档的备注信息,如下图: 以前思路老纠结在OOS这个在线上,总有以为这个信息存储在某个列表中,其实错了,这个备注信息 ...
随机推荐
- this、apply、call的指向
1.关于this this它总是返回一个对象,是指调用当前函数的对象,由于对象的属性可以赋给另一个对象,所以属性所在的当前对象是可变的,即this的指向是可变的. var person={ name: ...
- Mysql中WHERE IN,UNION 用法详解
WHERE IN 用法 这里分两种情况来介绍 1.in 后面是记录集,如: select * from table where uname in(select uname from ...
- MapReduce的编程思想(1)
MapReduce的编程思想(1) MapReduce的过程(2) 1. MapReduce采用分而治之的思想,将数据处理拆分为主要的Map(映射)与Reduce(化简)两步,MapReduce操作数 ...
- ImageLoader常用方法注释
ImageLoader中的常用方法及相关作用注释 ImageLoader 的ImageLoaderConfiguration config 配置 ImageLoaderConfiguration co ...
- 基于 Ubuntu + nextCloud 搭建自己的私人网盘
提醒一下,如果之前通过apache搭建了网站,不要用snap命令来搭建,否则,至少有一个无法正常运行(不要问我怎么知道的,都是血的教训啊). 你可以通过腾讯云的实验主机进行尝试. 1.基础设置 切换为 ...
- pycharm创建工程的两种形式:virtualenv环境和系统默认编译器
转自:http://swiftlet.net/archives/3151 pycharm创建工程的时候可以选择编译器,如下图所示: 上图表示创建工程有两种方式:第一种是利用:virtualenv,第二 ...
- vue 中根据地址名称获取实际经纬度方法
<div id="container" class="map" style="margin-top:30px; width: 1200px;he ...
- 在DataGridView控件中设置数据显示格式
实现效果: 知识运用: DataGridViewCellStyle类的Format属性 //获取或设置应用于DataGridView单元格的文本内容的格式字符串 public string Forma ...
- python_81_标准库_时间模块
''' 标准库: 1.time 时间的三种表示方法:a:时间戳(timestamp) b:格式化的时间字符串 c:元组(struct_time)共九个元素 time.struct_time(tm_ye ...
- npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\James\package.json'
在运行如下命令时, 遇到了问题: npm install --registry=https://registry.npm.taobao.org npm run dev 错误提示: 解决办法: 生成一个 ...