zoukankan      html  css  js  c++  java
  • iOS的几种页面跳转方式

    前言

    对于新手来说,iOS的几种跳转方式还挺繁琐的,下面就来一一介绍

    1.不带任何布局文件的viewController之间的跳转

    MyViewController *vc = [[MyViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];

    2.带.xib布局文件的viewController之间的跳转

    //在初始化的时候需要使用initWithNibName函数,并且里面的名称要和xib文件名称保持一致
    MyViewController *vc = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
    [self.navigationController pushViewController:vc animated:YES];

    3.带.storyboard布局文件的viewController之间的跳转

    MyViewController *vc = [[UIStoryboard storyboardWithName:@"MyViewController" 
    bundle:nil] instantiateInitialViewController];
    [self.navigationController pushViewController:vc animated:NO];

    4.storyboard文件中viewController的跳转
    首先storyboard本身提供了很多便捷的方式帮助我们构建布局文件,直接可以通过“连线”操作就可以实现viewContoller之间的跳转,storyboard可以看作是一个页面集合或者viewController的集合。这样不仅可以减少我们编写的代码量,也方便我们查看页面之间的跳转逻辑,下面我简单地说一下,操作方式

    新建几个viewController,使用按住control和左键(触摸板按下去),拖动,就会出现一条带箭头的线,然后移动到你想要跳转的viewController中,释放它,就是出现几个action选项,一般选show即可

     

    总结

    至此,iOS的几种跳转方式已经说完了,其实还有其他方式,我这里就说了几种常见的,方便iOS的新手朋友可以快速上手

  • 相关阅读:
    元祖操作
    列表操作
    字符串操作
    zabbix监控脚本
    nginx 使用php-fpm的配置php环境参数
    网卡切换脚本
    mysql数据备份脚本
    docker概念
    网络链路质量监控smokeping
    搭建speedtest
  • 原文地址:https://www.cnblogs.com/Im-Victor/p/13212886.html
Copyright © 2011-2022 走看看