从 XIB-file-Button 显示 ViewController - Swift [英] Show ViewController from XIB-file-Button - Swift

查看:26
本文介绍了从 XIB-file-Button 显示 ViewController - Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从 xib 文件(自定义 TableViewCell)segue 到 Main.storyboard 中的另一个 ViewController.

is there a way how to segue from a xib-file (custom TableViewCell) to another ViewController in the Main.storyboard.

不可能像在主故事板中那样拖动转场.

There's no possibility to drag a segue, like within the main storyboard.

在单元格中,我有一个按钮,我想从中更改视图.我该如何解决?

In the cell I've got a button, from where I want to change the view. How can I solve it?

谢谢!

推荐答案

你总是可以从 Storyboard 实例化一个视图控制器,并在点击按钮时呈现它:

You can always instantiate a view controller from your Storyboard and present it on button tapped:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("ViewControllerID") as UIViewController
    self.presentViewController(vc, animated: true, completion: nil)

这篇关于从 XIB-file-Button 显示 ViewController - Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆