码迷,mamicode.com
首页 > 其他好文 > 详细

Swfit中视图跳转

时间:2015-11-30 09:56:37      阅读:211      评论: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/Free-Thinker/p/5006305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!