开始学习swift Ihpone编程开发,发现swift的资料真是不好找,只能自力更生,这两天搞了一下页面跳转功能。一共有两种,自动和代码跳转。这里介绍手动代码跳转,在另一个经验里介绍了自动跳转。
方法/步骤
-
在添加代码之前,我们先要使用storyboard进行一些设置,首先点选右图顶端的ViewControl按钮
-
选择属性栏的第三项如下图,并确保ViewControl处于选中状态
-
在Identifyt选项中填写 "storyboard ID"为post。这个ID根据自已的情况填写,后面的代码中会用到。
-
重点来了,为登录按钮添加页面跳转代码
@IBAction func LoginButtonLicked(sender: AnyObject){
let myStoryBoard = self.storyboard
let anotherView:UIViewControl = myStoryBoard.instanceViewControllerWithIdentifier("post") as UIViewControl
self.presentViewController(anotherView, animated: true, completion: nil)
}
-
测试,正常跳转
END