UIViewController三种不同的初始化view的方式
You can specify the views for a view controller using a Storyboard created in Interface Builder. A storyboard contains preconfigured view controllers and their associated views and is the preferred way to develop your app'ss user interface. A key advantage of storyboards is that they can express relationships between different view controllers in your app. For example, you can state that one view controller's contents are contained inside another view controller or that a view controller is displayed as a transition (known as a segue) from another view controller . By allowing you to see the relationships between view controllers, storyboards make it easier to understand your app's behavior at a glance.
At runtime, the view controller uses the storyboard to automatically instantiate and configure its views. Often, the view controller itself is automatically created by segues defined in the storyboard. When you define a view controller's contents using a storyboard, you never directly allocate and initialize the view controller object. Instead, when you need to programmatically instantiate the view controller, you do so by calling the
instantiateViewControllerWithIdentifier:method on aUIStoryboardobject.You can specify the views for a view controller using a nib file, also created in Interface Builder. Like a storyboard, a nib file allows you to create and configure a set of views. However, you cannot easily create or see the relationships between view controllers using nib files as you can when using storyboards.
To initialize your view controller object using a nib, you use the
initWithNibName:bundle:method to specify the nib file used by the view controller. Then, when the view controller needs to load its views, it automatically creates and configures the views using the information stored in the nib file.If you cannot define your views in a storyboard or a nib file, override the
loadViewmethod to manually instantiate a view hierarchy and assign it to theviewproperty.
IMPORTANT
A view controller is the sole owner of its view and any subviews it creates. It is responsible for creating those views and for relinquishing ownership of them at the appropriate times such as when the view controller itself is released. If you use a storyboard or a nib file to store your view objects, each view controller object automatically gets its own copy of these views when the view controller asks for them. However, if you create your views manually, you should never use the same view objects with multiple view controllers.
UIViewController三种不同的初始化view的方式的更多相关文章
- 三种POST和GET的提交方式
向服务器提交数据有两种方式,post和get.两者的区别主要有三点,安全性.长度限制.数据结构.其中get请求安全性相比较而言较差,数据长度受浏览器地址栏限制,没有方法体.两种都是较为重要的数据提交方 ...
- Spring的三种通过XML实现DataSource注入方式
Spring的三种通过XML实现DataSource注入方式: 1.使用Spring自带的DriverManagerDataSource 2.使用DBCP连接池 3.使用Tomcat提供的JNDI
- Android三种基本的加载网络图片方式(转)
Android三种基本的加载网络图片方式,包括普通加载网络方式.用ImageLoader加载图片.用Volley加载图片. 1. [代码]普通加载网络方式 ? 1 2 3 4 5 6 7 8 9 10 ...
- Hive三种不同的数据导出的方式
转自:http://blog.chinaunix.net/uid-27177626-id-4653808.html Hive三种不同的数据导出的方式,根据导出的地方不一样,将这些方法分为三类:(1)导 ...
- 三种不同实现初始化和销毁bean之前进行的操作的比较
Spring容器中的bean是有生命周期的,Spring 允许在 Bean 在初始化完成后以及 Bean 销毁前执行特定的操作,常用的设定方式有以下三种: 通过实现 InitializingBean/ ...
- linux下三种服务开机自启的方式
方式一.二.三适用于ubuntu,centos推荐使用方式二.方式三 方式一 在ubuntu系统中,如果你使用的apt方式安装的软件,可以使用如下方式直接添加服务的开机自启, 如果你是手动解压缩官网下 ...
- C#中三种弹出信息窗口的方式
弹出信息框,是浏览器客户端的事件.服务器没有弹出信息框的功能. 方法一: asp.net页面如果需要弹出信息框,则需要在前台页面上注册一个javascript脚本,使用alert方法.使用Client ...
- Struct2中三种获取表单数据的方式
1.使用ActionContext类 //1获取ActionContext对象 ActionContext context = ActionContext.getContext(); //2.调用方法 ...
- ListView适配器获取布局文件作为View的三种方式
第一种方法: public View getView(int position, View convertView, ViewGroup parent) { View view = null; if ...
随机推荐
- shell统计日志
#nginx日志统计独立ip的个数: awk '{print $1}' /path-to-log-dir/access.log | sort | uniq | wc -l #查询访问最多的前10个ip ...
- windows+Linux【Composer安装指定版本laravel】
在windows下安装的方法:(php.ini中openssl.dll扩展必须打开,且版本>=5.4) 方法一:使用安装程序 这是将 Composer 安装在你机器上的最简单的方法. 下载并且运 ...
- JavaScript常用語句
1.document.write(""); 输出语句2.JS中的注释为//3.传统的HTML文档顺序是: document->html->(head,body)4 ...
- socket 的粘包问题解决方案
粘包: 由于接受recv有最大限制,管道中有大于最大限制字节时, 第二次recv的会是之前残留的信息,这种现象叫做粘包. TCP协议是面向连接的,面向流的,当在发送数据时接受方不知道要收多少字节的数据 ...
- IOS性能调优系列:使用Allocation动态分析内存使用情况
硬广:<IOS性能调优系列>第三篇,持续更新,欢迎关注. <IOS性能调优系列:Analyze静态分析>介绍了使用静态分析方法查找IOS内存泄漏的方法,<IOS性能调优系 ...
- 在一个SQL Server表中一行的多个列找出最大值
有时候我们需要从多个相同的列里(这些列的数据类型相同)找出最大的那个值,并显示 这里给出一个例子 IF (OBJECT_ID('tempdb..##TestTable') IS NOT NULL) D ...
- Redis(十四):主从复制
当数据量变得庞大的时候,读写分离还是很有必要的.同时避免一个redis服务宕机,导致应用宕机的情况,我们启用sentinel(哨兵)服务,实现主从切换的功能. 主从复制 Redis 支持简单且易用的主 ...
- 设置CentOS控制台分辨率图文详解
最小化安装CentOS,默认是没有图形界面的,这个正合我意.但是命令行界面很小,会有很多输出被迫换行写,影响美观. 那么,怎样调整终端分辨率呢 解决方案:修改引导程序配置 /boot/grub/gru ...
- atitit.高性能遍历 文本文件行 attilax总结
atitit.高性能遍历 文本文件行 attilax总结 文件读写有以下几种常用的方法 1 通常io读取2.5s 1 nio读取或许越高的.. 2 NIO通常采用Reactor模式,AIO通常采用Pr ...
- Decoration6:改数据结构为继承的关系
一个家装市场有各种登录的角色:设计师.业主…… 这些角色有一些共同的字段,例如passWord,userName,age等等,但是分别又有自己的一些特殊字段,例如设计师要写自己的设计经历,业主可能要有 ...