zoukankan      html  css  js  c++  java
  • IOS开发—segue几种模式的介绍以及几种创建方式

    segue的几种模式

    1)xcode6 之后push 和modal 就被废弃了。只能用于ios8之前。

    2)可用的有五种,Show、Show Detail、Present Modally、Present as Popover、Custom

    官方解释:https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/Chapters/StoryboardSegue.html

     

    Show

    根据当前屏幕中的内容,在master area或者detail area中展示内容。

    例如:如果app当前同时显示master和detail视图,内容将会压入detail区域。

    如果app当前仅显示master或者detail视图,内容则压入当前视图控制器堆栈中的顶层视图。

     

    Show Detail

    在detail area中展现内容。

    例如:即使app同时显示master和detail视图,那么内容将被压入detail区域

    如果app当前仅显示Master或者detail视图,那么内容将替换当前视图控制器堆栈中的顶层视图。

     

    Present Modally

    使用模态展示内容。属性面板中提供presentation style (UIModalPresentationStyle)与 transition style (UIModalTransitionStyle)两种选项

     

    Present as Popover

    在当前的view上出现一个小窗口来展示内容,无处不在的“选中文字后出现 复制/翻译 按钮就是这个

    Custom 

    自定义跳转方式,可自定义跳转动画

    segue的几种创建方式

    1、在起始页面的button上按住ctrl键,拖动到目标页面,在弹出的框中选择Show

    2、在起始页的controller上按ctrl键,拖动到目标页面,选择Show。

    然后选中两个页面连线,在下图红框处给这个Segue命名:

    最后在View Controller想触发跳转的地方(就比如点击按钮,则在按钮的点击事件的方法中)添加下面代码:

    [self performSegueWithIdentifier:@“segue名” sender:nil];

    则可实现跳转。

    跳转到新的页面后要返回上一个页面,则在需要返回的地方添加以下代码

    [self dismissModalViewControllerAnimated:true];

    参数true与false代表的是跳转的页面的切换时是否使用动画

    3、纯代码创建

    在起始页的controller中设置button的点击事件,在点击事件中设置以下代码

        SecondViewController *sVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"secondVC"];
        [self showViewController:sVC sender:nil];

    要在目标页面的storyboard中设置Storyboard ID 上端代码为secondVC,要从storyboard中找到controller。

  • 相关阅读:
    06-局部变量和全局变量
    05-python中函数的使用
    04-字典的常见操作
    04-python第四天学习
    Openstack认证过程
    03-字典的增删改查
    01-名字管理系统.py
    02-python中列表的增删改查
    01-python中字符串的常见操作
    ubuntu16.04卸载软件
  • 原文地址:https://www.cnblogs.com/saurik/p/4952219.html
Copyright © 2011-2022 走看看