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的新手朋友可以快速上手

  • 相关阅读:
    flutter  安装教程
    使用TcpTrace小工具截获Web Service的SOAP报文
    移除TFS服务器关系
    webservice log4net日志写入失败
    php发送邮件功能(PHPMailer-master插件)
    Unity3d:延迟加载ScrollView的内容
    Unity3d:播放物理目录下的MP3文件
    installshield Basic 工程每次安装完提示重启电脑
    网站背景音乐源码
    Unity3d:加载Format是RGB24位的图片失败(加载图片显示问号)
  • 原文地址:https://www.cnblogs.com/Im-Victor/p/13212886.html
Copyright © 2011-2022 走看看