400-800-9385
网站建设资讯详细

APP开发之IOS SWIFT页面跳转方法全解析

发表日期:2016-01-09 00:00:00   作者来源:方维网络   浏览:7675   标签:APP开发    IOS    SWIFT    

在网站制作中,页面跳转使用超链接,A标签,非常方便简单,但是在IOS APP开发中就没那么容易了,需要写比较多的代码,方维网络以下为你一一分享APP页面跳转方法全解。

APP页面跳转

一、 使用StoryBoard点击按钮直接跳转到新页面

按住Ctrl键,拖动连接线到目标页面,弹出窗口选择modal 则为新页面
如果要选择push,则原页面要实现Navigation导航

二、 利用Segue代码跳转

在起始页面按住Ctrl键拖动连接线到目标页面,弹出窗口选择动作类型,然后选中页面连线,属性框中命名Indetifier,然后中页面代码处需要跳转地方使用
self.performSegueWithIdentifier ("CatSegue", sender: nil)
 

三、 代码PUSH

let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
        let vc = mainStoryboard.instantiateViewControllerWithIdentifier("CategoryViewController") as! CategoryViewController
 self.navigationController.pushViewController(vc, animated:true)
 

四、 代码Modal

let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
        let vc = mainStoryboard.instantiateViewControllerWithIdentifier("CategoryViewController") as! CategoryViewController
self.presentViewController(vc, animated: true, completion: nil)
 
如没特殊注明,文章均为方维网络原创,转载请注明来自https://www.szfangwei.cn/news/2852.html