Swfit中視圖跳轉


1.跳轉到任一UIViewController

var sb = UIStoryboard(name: "Main", bundle:nil)
var vc = sb.instantiateViewControllerWithIdentifier("ChooseViewController") as ChooseViewController
self.presentViewController(vc, animated:true, completion:nil)

2.從當前視圖跳轉到下一視圖

var vc = AnswerViewController()
self.presentViewController(vc, animated: true, completion: nil)

3.通過dismissViewControllerAnimated(completion:)返回上一個視圖

self.dismissViewControllerAnimated(true, completion:nil)

4.Modal Segue to channel Controller
通過在storyboard設計視圖中,選擇一個按鈕,右鍵拖動到另一個視圖,即可建立動作跳轉,但需要重載func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!)方法,如下:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
var channelC:ChannelController=segue.destinationViewController as ChannelController
channelC.delegate=self
channelC.channelData=self.channelData
}

5.通過navigationController.pushViewController(animated:)方法

var webView=WebViewController()
webView.detailID=data.newsID
//取導航控制器,添加subView
self.navigationController.pushViewController(webView,animated:true)

6.通過 func popViewControllerAnimated() -> UIViewController! 彈出最上面的視圖,並返回下一個視圖控制器

7.通過func popToViewController(animated:) -> AnyObject[]!返回到navigationController視圖堆棧中指定的某一個視圖

歡迎完善。。。。

 

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com