xcode 如何将表视图控制器的类型更改为常规视图控制器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11535297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:55:39  来源:igfitidea点击:

How can I change Table View Controller's type to a regular View Controller?

iphoneobjective-ciosxcodestoryboard

提问by hyouuu

I followed the "Storyboard tutorial" and made some Table View Controllers; now I want to change one of them to a regular View Controller.

我按照“故事板教程”制作了一些表格视图控制器;现在我想将其中一个更改为常规视图控制器。

Is there a way to do that without making a new one?

有没有办法在不制作新的情况下做到这一点?

采纳答案by lu yuan

You need to create a new view controller and drag a tableview into it. Remember to set the delegate and datasource of the tableview to the view controller.

您需要创建一个新的视图控制器并将 tableview 拖入其中。请记住将 tableview 的委托和数据源设置为视图控制器。

回答by nortchuck

One option is to edit the storyboard file directly. Navigate to the Storyboard in Finder and open with any text editor. Find the view controller in question and change the node in the xml from tableViewControllerto viewController.

一种选择是直接编辑情节提要文件。在 Finder 中导航到 Storyboard 并使用任何文本编辑器打开。找到有问题的视图控制器并将 xml 中的节点从 更改tableViewControllerviewController

This saves the pain of having to recreate the view controller, which comes in handy when you have a lot of connections made. This also works the other way around. If you have a viewController that started out as a plain view controller but you want to turn it into a table view controller you can simply edit the file reversing the node.

这省去了重新创建视图控制器的痛苦,当你有很多连接时,它会派上用场。这也适用于相反的情况。如果你有一个 viewController 最初是一个普通的视图控制器,但你想把它变成一个表视图控制器,你可以简单地编辑文件反转节点。

回答by GenieWanted

I have had the same scenario where I needed to change the Tableviewcontroller to a view controller. I googled for a work around but ended up without an exact solution. What I did was added a subclass of view controller and dropped a UITableview and added some more controls that I wanted. Pretty inconvenient but worked the way eventually!

我遇到了同样的场景,我需要将 Tableviewcontroller 更改为视图控制器。我用谷歌搜索了一个解决方法,但最终没有一个确切的解决方案。我所做的是添加了一个视图控制器的子类并删除了一个 UITableview 并添加了一些我想要的控件。相当不方便,但最终还是成功了!