美文网首页
页面跳转与返回

页面跳转与返回

作者: MakeThatChange | 来源:发表于2016-05-30 15:21 被阅读104次

———————— ————————————————————————

storyboard中的每个View Controller,想要实现一些操作,都必须添加关联的类

里面自带的那个View Controller已近关联了自带的ViewController

————————————————————————————————

一.storyBoard实现(点击页面一按钮,跳转页面二. 点击页面二按钮,返回页面一(

1.创建一个Button (跳转)创建— 将Button与下一页关联Modal

2.在StoryBoard中拖入View Controller,添加返回按钮

3.需要实现返回按钮的返回操作,必须关联外面的一个继与UIViewContrller的类,在类中实现Button的点击方法关联

————————————————————————————————————————————————

二.使用代码的方法实现

1.懒加载创建UIButton— 添加点击事件

2.创建下一页的ViewController

3.点击事件

- (void)gotoNextPage:sender{

//根据名字取到storyboard的引用

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

//根据storyboard取到ViewController

   UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"PurpleViewController"];

   //动画的设置

   vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

//根据ViewController推出视图

   [self presentViewController:vc animated:YES completion:nil];

}

相关文章

网友评论

      本文标题:页面跳转与返回

      本文链接:https://www.haomeiwen.com/subject/jmfcdttx.html