Storyboard 常用方法总结-精华版

1.prepareForSegue:

Now we know what the destinationViewController is we can set its data properties. To receive information back from a scene we use
delegation. Both are shown simply in the following code snipped.

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"ContactsViewControllerSegue"]){
         ContactsViewController *cvc = (ContactsViewController *)[segue destinationViewController];
         cvc.contacts = self.contacts;
         cvc.delegate = self;
     }
}

A final note about UIStoryboardSegue is that when you choose a popover transition you must get access to the popover in order to dismiss it. You can get this by casting the Segue to a UIStoryboardPopoverSegue but only after you have checked the identity of
the Segue to ensure you are making the correct cast.

2.UITableViewCell:

 static NSString *CellIdentifier = @"ContactsCell";
    ContactsTableViewCell *cell = (ContactsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.contact = [contacts objectAtIndex:indexPath.row];

Note: That you can have as many different prototype cells as you wish the only requirement is that you set each one with a unique cell identifier.

It is also possible to create Segues between cells and ViewControllers to transition to a new scene when a cell is tapped. In the following screen shot you can see how to connect a cell to a UIViewController and by specifying Push as the transition mode we
now have a detailed view pushed on whenever a cell is tapped.

3.UIViewController:

UIStoryboard is a runtime representation of everything configured inside Interface Builder as such any individual scene can be loaded using either,

[UIStoryboard instantiateInitalViewController]
[UIStoryboard InstantiateViewControllerWithIdentifier]

Should you choose to split your application across multiple Storyboards these can be loaded using,

[UIStoryboard storyboardWithName:bundle:]

时间: 2024-08-25 08:37:24

Storyboard 常用方法总结-精华版的相关文章

Sublime Text 3 快捷键精华版

Sublime Text 3 快捷键精华版 Ctrl+Shift+P:打开命令面板Ctrl+P:搜索项目中的文件Ctrl+G:跳转到第几行Ctrl+W:关闭当前打开文件Ctrl+Shift+W:关闭所有打开文件Ctrl+Shift+V:粘贴并格式化Ctrl+D:选择单词,重复可增加选择下一个相同的单词Ctrl+L:选择行,重复可依次增加选择下一行Ctrl+Shift+L:选择多行Ctrl+Shift+Enter:在当前行前插入新行Ctrl+X:删除当前行Ctrl+M:跳转到对应括号Ctrl+U:

【知识学习】Sublime Text 快捷键精华版

1 Sublime Text 3 快捷键精华版 2 Ctrl+Shift+P:打开命令面板 3 Ctrl+P:搜索项目中的文件 4 Ctrl+G:跳转到第几行 5 Ctrl+W:关闭当前打开文件 6 Ctrl+Shift+W:关闭所有打开文件 7 Ctrl+Shift+V:粘贴并格式化 8 Ctrl+D:选择单词,重复可增加选择下一个相同的单词 9 Ctrl+L:选择行,重复可依次增加选择下一行 10 Ctrl+Shift+L:选择多行 11 Ctrl+Shift+Enter:在当前行前插入新行

Storyboard 经常用法总结-精华版

1.prepareForSegue: Now we know what the destinationViewController is we can set its data properties. To receive information back from a scene we use delegation. Both are shown simply in the following code snipped. -(void)prepareForSegue:(UIStoryboard

传智播客 刘意_2015年Java基础视频-深入浅出精华版 笔记(day11~)(2016年2月3日16:01:00)

day11 1.Eclipse的基本使用 编译: 自动编译,在保存的那一刻(ctrl+s)帮你做好了(class文件出现在bin目录下) 2.Hierarchy 显示Java继承层次结构,选中类后F4 3.eclipse行号的显示与隐藏 4.D:字体大小及颜色 a:Java代码区域的字体大小和颜色: window -- Preferences -- General -- Appearance -- Colors And Fonts -- Java修改 -- Java Edit Text Font

iOS 中快速简单高效的实现自定义tableViewCell 的方法-亲测实战版本-精华版

ios7 新升级之后界面有了很大的变化,xcode模拟器去掉了手机边框和home键,如果想回到主页面,可以按住shift+comment+r键.废话少说先展示一下新UI下UItableView设置为Group后的效果: 整体界面显得更加简洁,而且UITableViewCell的宽度默认为满屛,也取消了圆角. 下面说下自定义UITableView的过程: 首先在storyboard中给cell拖过来一个UIimageView和两个label 然后新建一个MyCell类继承自UITableViewC

sqlalchemy精华版

上一篇主要粗略讲了Flask+mysql+sqlalchemy的使用,这次精讲下sqlalchemy的用法,话不多说,上代码. ----------sqlalchemy_test.py # -*- coding: utf-8 -*- # Flask hello world ##链接数据库 mysql from sqlalchemy import * from sqlalchemy.orm import scoped_session, sessionmaker ###连接数据库 db_connec

一看就懂的ReactJs入门教程(精华版)

现在最热门的前端框架有AngularJS.React.Bootstrap等.自从接触了ReactJS,ReactJs的虚拟DOM(Virtual DOM)和组件化的开发深深的吸引了我,下面来跟我一起领略ReactJS的风采吧~~ 章有点长,耐心读完,你会有很大收获哦~ 一.ReactJS简介 React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.做出来以后,发现这套东西很好用

getline函数(精华版)

在我的印象中,getline函数经常出现在自己的视野里,模糊地记得它经常用来读取字符串 .但是又对它的参数不是很了解,今天又用到了getline函数,现在来细细地总结一下: 首先要明白设计getline函数的目的,其实很简单,就是从流中读取字符串.而且读取的方 式有很多,包括根据限定符,根据已读取的字符的个数.从这个函数的名称来看,它的直观 意义是从流中读取一行,但是大家不要被这表面的现象所迷惑.其实如果让我来为这个函数 去一个名字的话,或许我会取一个getString,因为它的目的本来就是从流

传智播客_2015年Java基础视频-深入浅出精华版 笔记(2015年9月14日23:11:11)

本笔记是个人笔记+摘录笔记相结合,非完全原创 day01 win 7系统打开DOS有趣方法:按住shift+右键,单击“在此处打开命令窗口”(注意:在此处可以是任何的文件夹,不一定是桌面) 用DOS删除的文件不可以在回收站恢复?!! 常用DOS命令d: 回车 盘符切换dir(directory):列出当前目录下的文件以及文件夹md (make directory) : 创建目录(创建文件夹)rd (remove directory): 删除目录(删除文件夹,注意:前提是文件夹必须是空的!!)如果