swift页面跳转的集中方式归纳
2015-12-01 14:04
323 查看
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, animated: true, completion: nil)
//////push方式
self.navigationController.pushViewController(vc, animated:true) //返回是pop
//////present方式
self.presentViewController(vc, animated: true, 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的属性赋值,然后在后一个页面就可以得到值
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, animated: true, completion: nil)
//////push方式
self.navigationController.pushViewController(vc, animated:true) //返回是pop
//////present方式
self.presentViewController(vc, animated: true, 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的属性赋值,然后在后一个页面就可以得到值
相关文章推荐
- Swift简单的本地存储方式NSUserDefaults
- 《swift2.0 官方教程中文版》 第2章-13继承
- Swift 值类型,引用类型,深拷贝,浅拷贝,Copy,MutableCopy
- Swift 数组
- 《swift2.0 官方教程中文版》 第2章-12下标脚本
- Swift之手势解
- 单例-------OC中单例 / Swift中单例
- Swift -6 面向对象基础(下)
- 【IOS开发】swift版的AFNETworking之Alamofire的用法 图片上传
- IOS_Swift_enum枚举方法
- Swift中如何在一行中定义多个变量
- Swift String 扩展
- swift 用协议实现代理传值功能
- 百度地图 API 使用过程记录(OC&SWIFT)
- 【iOS】swift 枚举
- 【iOS】swift 枚举
- 去掉webView滚动条 swift
- swift 用协议实现代理传值功能
- Swift:表格视图单元格单选(二)
- 关于在用Swift开发iOS时如何隐藏NavigationBar和TabBar