iOS 7 点击按钮切换视图

来源:互联网 发布:淘宝客服没经验能干吗 编辑:程序博客网 时间:2024/05/17 12:03

(1)创建一个项目,名字为切换视图


(2)打开Main.storyboard文件,将视图中的ViewController视图控制器拖动到画布中。

(3)将视图库中的Button控件视图拖动到两个Viewcontroller视图控制器的设计界面。

(4)按住ctrl键,拖动按钮一到按钮二上,会出现一个action segue 对话框,选择 mode选项,这时新增一个箭头。

(5)如步骤4,按住ctrl键,拖动按钮二到按钮一上,会出现一个action segue 对话框,选择 mode选项,这时新增一个箭头。

segue共有三种类型:push,modal,和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一起使用。
 custom
就是自定义跳转方式啦。


如图所示 ,一个简单的切换视图就做好了,点击按钮一会切换到有按钮二的视图,点击按钮二回切换到有按钮一的视图。





0 0
原创粉丝点击