加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift实现IOS界面的跳转

发布时间:2020-12-14 06:05:11 所属栏目:百科 来源:网络整理
导读:IOS开发中界面跳转有两种方式,上下跳转和左右跳转。 上下跳转_TO: [objc] view plain copy print ? letsecondViewController=SecondViewController() self .presentViewController (secondViewController, animated : true ,0); background-color:inherit"

IOS开发中界面跳转有两种方式,上下跳转和左右跳转。

上下跳转_TO:

[objc] view plain copy
print ?
  1. letsecondViewController=SecondViewController()
  2. self.presentViewController(secondViewController,animated:true,0); background-color:inherit">completion:nil)

上下跳转_BACK:

copy
dismissViewControllerAnimated(nil)

-----------------------------------------------

-----------------------------------------------

左右跳转_TO:

(将新的视图控制器PUSH到navigationController中,相当于入栈操作)

copy
self.navigationController!.pushViewController(secondViewController,255); background-color:inherit; font-weight:bold">true)

左右跳转_BACK:

(将当前视图控制器从导航视图控制器堆栈中移除,从而返回到了上一级界面)

( - ) BACK_到上一级:

copy
letfirstViewController=FirstViewController()
  • self.navigationController?.popViewControllerAnimated(true)

  • ( - )BACK_指定界面:

    copy
    //获得视图控制器中的某一视图控制器
  • letviewController=self.navigationController?.viewControllers[0]
  • self.navigationController?.popToViewController(viewControlleras!UIViewController,255); background-color:inherit; font-weight:bold">true)

  • ( - )BACK_根视图:

    copy
    self.navigationController?.popToRootViewControllerAnimated(true)

    根视图的设置需要在AppDelegate中设置:

    copy
    varwindow:UIWindow?
  • funcapplication(application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[NSObject:AnyObject]?)->Bool
  • {
  • varfirstViewController=FirstViewController()
  • varrootNavigationViewController=UINavigationController(rootViewController:firstViewController)
  • self.window!.rootViewController=rootNavigationViewController
  • returntrue
  • }
  • (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读