【iOS】iOS开发视图跳转:利用storyboard简单实现视图的跳转与返回

来源:互联网 发布:vmware tools linux 编辑:程序博客网 时间:2024/05/16 12:34

iOS开发视图跳转:利用storyboard简单实现视图的跳转与返回

1.新建项目,选择Singell View Application

2.在storyboard中选中ViewController,取消右边属性Auto Layout的勾选

3.添加一个新的ViewController,为了与第一个视图有好的区分,我们在新添加的ViewController中添加一个Image View并加上一张图片(此步骤非必须)

4.在第一个和第二个ViewController中分别添加一个按钮“下一页”、“返回”

5.首先实现视图一到视图二的跳转:按住control键,拖动“下一页”按钮到视图二,松开后选择“modal”
这里写图片描述
6.视图二返回视图一的实现
新建一个Cocoa Touch Class,取名SecondViewController,继承自UIViewController
storyboard中选择视图二,在右边属性中绑定class:SecondViewController
这里写图片描述
按住control键,拖拽“返回”按钮在SecondViewController.h中添加一个动作,名称为BtnAction
这里写图片描述
ImageViewController.m中生成的动作中添加方法 [self dismissViewControllerAnimated:YES completion:nil];
这里写图片描述
完成

0 0
原创粉丝点击