首页 > 其他 > 详细

Swfit中视图跳转

时间:2016-02-19 12:08:36      阅读:87      评论:0      收藏:0      [点我收藏+]

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视图堆栈中指定的某一个视图

Swfit中视图跳转

原文:http://www.cnblogs.com/yesicoo/p/5200456.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!