一、视图切换类型介绍
在storyboard中,segue有几种不同的类型,在iphone和ipad的开发中,segue的类型是不同的。
在iphone中,segue有:push,modal,和custom三种不同的类型,这些类型的区别在与新页面出现的方式。
而在ipad中,有push,modal,popover,replace和custom五种不同的类型。

modal 模态转换

 
最常用的场景,新的场景完全盖住了旧的那个。用户无法再与上一个场景交互,除非他们先关闭这个场景。
是在viewController中的标准切换的方式,包括淡出什么的,可以选切换动画。
Modalview:就是会弹出一个view,你只能在该view上操作,而不能切换到其他view,除非你关闭了modalview.
Modal View对应的segue type就是modal segue。
*Modal:Transition to another scene for the purposes of completing a task.当user在弹出的modalview里操作完后,就应该dismiss the modal view scene然后切换回the originalview.

push

Push类型一般是需要头一个界面是个Navigation Controller的。
是在navigation View Controller中下一级时使用的那种从右侧划入的方式
*Push:Create a chain of scenes where the user can move forward or back.该segue type是和navigation viewcontrollers一起使用。

popover(iPad only)

 
popover 类型,就是采用浮动窗的形式把新页面展示出来
*Popover(iPad only):Displays the scene in a pop-up “window” over top of the current view.
 
 

*Replace (iPad only):

 
替换当前scene,
Replace the current scene with another. This is used in some specialized iPad viewcontrollers (e.g. split-view controller).

custom

就是自定义跳转方式啦。
*Custom:Used for programming a customtransition between scenes.
在Storyboard中使用自定义的segue类型
参考资料:
使用StoryBoard:用Segue传递数据
http://www.cnblogs.com/mybkn/archive/2012/03/22/2411842.html 
WWDC2011视频之Introduction to Storyboarding摘要
http://blog.sina.com.cn/s/blog_834f346f0100s4jr.html
storyboard 遇到一个segue的问题
http://www.cocoachina.com/bbs/simple/?t92552.html
 
二、StoryBoard的视图切换

一 、简述

Storyboard是你可以用来定义用户界面的一种新的方式,像xib。

与xib不同的是它可以同时管理多个ViewController,而且可以在Storyboard中配置ViewController 之间的跳转关系。

二、Storyboard使用

如果你是创建新项目,Xcode模版可以提供一个配置好的Storyboard供你使用。对于其它的应用,使用Storyboard的过程如下:

1、配置应用程序Info.plist文件

  • 添加UIMainStoryboardFile ,值为storyboard的文件名。
  • 删除原来的NSMainNibFile

2、像以前创建xib文件一样创建一个storyboard文件

3、配置 storyboard中的viewController

三、Storyboard的创建

你可以用InterfaceBuilder 去为你的应用程序创建一个Stroyboard,一般来说一个应用使用一个 Storyboard就够了,但是如果你想创建多个也是可以的,只要你愿意。一个 Stroyboard应该至少含有一个ViewController。

在iPhone中,对于每一个在Storyboard的ViewController都管理着一个scene,每个scene又管理着screen上的东东,但对于iPad来说,多个scene可以同时呈现在一个screen上。你可以从library中拖拽viewController到你的Storyboard上。

当你想关联两个viewController时,你可以按着control键,用鼠标从一个ViewController中的button,table view cell…拖拽连接到另一个你想跳转到的ViewController,这样就创建了一个segue,不要忘记设置identifier哦。

四、 Scene之间的数据传递

当你从当前 scene中触发一个segue的时候,系统会自动调用prepareForSegue:sender:这个方法。如果你想从一个界面切换到里另一个界面的时候传递数据,你应该override这个方法。

A---》B

想把数据  NSString A_data   从AController传到BController,则在BController中

@property 一个NSString data

然后在AController中添加方法

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

NSLog(@"The segue id is %@", segue.identifier );

UIViewController *destination = segue.destinationViewController;

if ([destination respondsToSelector:@selector(setData:)])

{

[destination setValue:@"这是要传递的数据" forKey:@"data"];

}

}

之后,Bcontroller中的data属性,就接收到数据了。

五、ViewController之间的跳转

1、如果在 Storyboard中当前的 ViewController和要跳转的ViewController之间的segue存在,则可以执行performSegueWithIdentifier:sender:这个方法实现跳转。

2、如果目标ViewController存在Storyboard中,但是没有segue。你可以通过UIStoryboard的instantiateViewControllerWithIdentifier:这个方法获取到它,然后再用你想要的方式实现跳转,如:压栈。

3、如果目标ViewController不存在,那就去创建它吧。

http://blog.csdn.net/piziliweiguang/article/details/8080426

Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom的更多相关文章

  1. Storyboard里面的几种Segue区别和视图的切换

    几种segue:push.modal.popover.replace.cutom. 一.视图切换类型介绍 1.在iPhone和iPad中,segue的类型是不同的. 2.在iPhone中,segue有 ...

  2. profile和bashrc四种的区别

    Linux下profile和bashrc四种的区别 12160阅读 0评论 /etc/profile./etc/bashrc.~/.bash_profile.~/.bashrc很容易混淆,他们之间有什 ...

  3. centos LB负载均衡集群 三种模式区别 LVS/NAT 配置 LVS/DR 配置 LVS/DR + keepalived配置 nginx ip_hash 实现长连接 LVS是四层LB 注意down掉网卡的方法 nginx效率没有LVS高 ipvsadm命令集 测试LVS方法 第三十三节课

    centos   LB负载均衡集群 三种模式区别 LVS/NAT 配置  LVS/DR 配置  LVS/DR + keepalived配置  nginx ip_hash 实现长连接  LVS是四层LB ...

  4. Hadoop Hive概念学习系列之hive三种方式区别和搭建、HiveServer2环境搭建、HWI环境搭建和beeline环境搭建(五)

     说在前面的话 以下三种情况,最好是在3台集群里做,比如,master.slave1.slave2的master和slave1都安装了hive,将master作为服务端,将slave1作为服务端. 以 ...

  5. 面试题:ApplicationContext和BeanFactory两种容器区别

    ApplicationContext和BeanFactory两种容器区别 BeanFactory是ApplicationContext容器的父接口 BeanFactory(多例模式): BeanFac ...

  6. [转]magento 2 modes – 每种模式的特点及如何切换(翻译)

    本文转自:https://www.hellomagento2.com/switch-magento-2-system-modes/ 原文地址 在开始 Magento 2 使用之前,需要了解一些基本的东 ...

  7. vue 中router.go;router.push和router.replace的区别

    vue 中router.go:router.push和router.replace的区别:https://blog.csdn.net/div_ma/article/details/79467165 t ...

  8. tableView主从表在storyboard连线是 Selcetion Segue和Accessory Action的区别

    当按住Ctorl这样连线时会出现,当选择Selection Segue下面的push时,点击cell的任何位置都会跳转到下一个tableView,当选择Accessory Action的下面的push ...

  9. [转]在Storyboard中使用自定义的segue类型

    转自:http://my.oschina.net/u/728866/blog/92709 我们知道segue共有三种类型:push.modal以及custom.如下图:   很明显,这三种类型的作用分 ...

随机推荐

  1. iOS开发 获取手机信息(UIDevice,NSBundle,NSlocale)

    在开发中,需要获取当前设备的一些信息,可以通过UIDevice,NSbundle,NSlocale获取. UIDevice UIDevice 提供了多种属性,类函数及状态通知,可以检测手机电量,定位, ...

  2. Testing the CATCHER_DP

    Description A military contractor for the Department of Defense has just completed a series of preli ...

  3. Golang Deco Enco

    mproto.go package mproto import ( "bytes" "encoding/binary" "fmt" &quo ...

  4. excel表里的数据导入到数据库里

    采用的是jxl,所以需要导jxl-2.4.2.jar的jar包.(前提知道excel表的目录): //用log记录异常信息 private static final Logger log = Logg ...

  5. 关于VS中更改栈和堆空间的大小

    编号:1008时间:2016年4月12日17:01:38功能:关于VS中更改栈和堆空间的大小 URL:http://blog.csdn.net/icerock2000/article/details/ ...

  6. 循环列表的Java实现,解决约瑟夫环问题

    import java.util.Scanner; /** * 循环列表的Java实现,解决约瑟夫环问题 * * @author LIU * */ public class LinkedList { ...

  7. 第一部分 python基础

    1.1,参数传递:*代表元组,**代表字典 1.2 ,常用数据类型 列表 [1,2,3] 元组 (1,2,3) 不可变的list 集合 {1,2,3} 字典 {1:a, 2:c} (4)字典以关键字为 ...

  8. CentOS下解决”用户账户is not in the sudoers file“问题

    如上图,在当前用户cent(我的用户名)下使用sudo命令时,提示"cent is not in the sudoers file. This incident will be report ...

  9. ZOJ 1188 DNA Sorting

    原题链接 题目大意:给定一串字符串,查找字符串里字母逆序排列的对数,按照由少到多的顺序把所有字符串进行排列. 解法:用C++字符串string类的iterator,从每个字符串的起始开始,查找逆序字符 ...

  10. 前端攻城狮学习笔记九:让你彻底弄清offset

    很多初学者对于JavaScript中的offset.scroll.client一直弄不明白,虽然网上到处都可以看一张图(图1),但这张图太多太杂,并且由于浏览器差异性,图示也不完全正确. 图一 不知道 ...