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

swift页面跳转的集中方式归纳

发布时间:2020-12-14 01:36:03 所属栏目:百科 来源:网络整理
导读:1.选择属性栏的第三项 2.在Identifyt选项中填写 "storyboard ID"为post。这个ID根据自已的情况填写,后面的代码中会用到 3.重点来了,为登录按钮添加页面跳转代码 @IBAction func LoginButtonLicked(sender: AnyObject){ let myStoryBoard = self.storyboard
1.选择属性栏的第三项 2.在Identifyt选项中填写 "storyboard ID"为post。这个ID根据自已的情况填写,后面的代码中会用到 3.重点来了,为登录按钮添加页面跳转代码 @IBAction func LoginButtonLicked(sender: AnyObject){ let myStoryBoard = self.storyboard let anotherView:UIViewControl = myStoryBoard.instanceViewControllerWithIdentifier("post") as UIViewControl self.presentViewController(anotherView,animated: true,completion: nil) } //和上面同一种方式,实现方法不同,上次使用时上面一种方式好像不能用了,可以选择1,2来选用 //显示列表 // let sb = UIStoryboard(name:"Main",bundle: nil) // let listController = sb.instantiateViewControllerWithIdentifier("demoList") as! DemoListViewController // self.presentViewController(listController,completion: nil) //////push方式 self.navigationController.pushViewController(vc,animated:true) //返回是pop //////present方式 self.presentViewController(vc,completion: nil) //返回改变vc为前一个 //////segue方式 拖线,然后重写方法prepareForSegue override func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject!) { if segue.identifier == "GoToGallery" { let index = beautyPicker.selectedRowInComponent(0) var vc = segue.destinationViewController as! GalleryViewController vc.imageName = "fanbingbing" } } /////返回方式 在前一个页面中重写一个方法,拖线到exit中后选择这个方法 @IBAction func close(segue: UIStoryboardSegue) { print("closed!") } ///////////////////////////最后说一句,传值都是得到要跳转的页面,然后为这个页面的controller的属性赋值,然后在后一个页面就可以得到值

(编辑:李大同)

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

    推荐文章
      热点阅读