ios UITableViewController 之外的静态表格视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22364230/
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-08-30 23:43:11  来源:igfitidea点击:

Static table view outside UITableViewController

iosiphonexcodecocoa-touch

提问by Francesco S

After the new Xcode update, my app doesn't validate and shows this error:

新的 Xcode 更新后,我的应用程序未验证并显示此错误:

static table views are only valid when embedded in UITableViewController instances

静态表视图仅在嵌入到 UITableViewController 实例中时才有效

Any chances to solve easily?

有机会轻松解决吗?

回答by LukeSideWalker

The only way to get a static UITableView along with other controls on the same screen is to use a Container View. Follow this way, it works perfectly:

在同一屏幕上获得静态 UITableView 和其他控件的唯一方法是使用容器视图。按照这种方式,它完美地工作:

  1. Drag a ViewController onto your storyboard.
  2. Drag a TableViewController onto your storyboard.
  3. Next Drag a Container view to your ViewController and size it about the size you want (smaller than the view) -> when you drag the container view it will create a segue and another view. Remove that segue and view.
  4. Then finally ctrl click in your container and drag to your new TableViewContoller. Select Embed.
  5. Style your TableView the way you want -> including static cells.
  1. 将 ViewController 拖到故事板上。
  2. 将 TableViewController 拖到故事板上。
  3. 接下来将一个容器视图拖到您的 ViewController 并将其调整为您想要的大小(小于视图)-> 当您拖动容器视图时,它将创建一个 segue 和另一个视图。删除该 segue 并查看。
  4. 然后最后 ctrl 单击您的容器并拖动到您的新 TableViewContoller。选择嵌入。
  5. 按照您想要的方式设置 TableView 样式 -> 包括静态单元格。

Good luck.

祝你好运。

This answer was already found and given here: G.Huebner -> http://web.archive.org/web/20140928102504/http://iphonedevsdk.com/forum/iphone-sdk-development/111800-static-table-view-cells-only-work-in-a-uitableviewcontroller.html

这个答案已经在这里找到并给出:G.Huebner -> http://web.archive.org/web/20140928102504/http://iphonedevsdk.com/forum/iphone-sdk-development/111800-static-table- view-cells-only-work-in-a-uitableviewcontroller.html

回答by Sahana Kini

A static UITableView must be in a UITableViewController. So you will have place the table in UITableViewController and then add it as childView to the MainViewController.

静态 UITableView 必须在 UITableViewController 中。所以你将把表放在 UITableViewController 中,然后将它作为 childView 添加到 MainViewController。

You can refer https://iphoneidoit.blogspot.in/2013/10/static-uitableview-in-uiviewcontroller.html

你可以参考 https://iphoneidoit.blogspot.in/2013/10/static-uitableview-in-uiviewcontroller.html

回答by hellosheikh

I think what you are doing is you are first dragging the ViewController on the storyboard and then dragging the tableView on the ViewController. In this way you can't use the Static table cells. Instead of this what you should have done is Drag the TableViewController on the main storyboard instead of a ViewController and then select the static cells. In this way you can be able to work on static cells and can use any elements on static cells.

我认为您正在做的是首先在情节提要上拖动 ViewController,然后在 ViewController 上拖动 tableView。这样你就不能使用静态表格单元格。而不是你应该做的是在主故事板上拖动 TableViewController 而不是 ViewController,然后选择静态单元格。通过这种方式,您可以处理静态单元格并可以使用静态单元格上的任何元素。

回答by River2202

Well, if you are really using a static tableView, you should consider copy/past everything to a ScrollView or StackView.

好吧,如果您真的在使用静态 tableView,则应该考虑将所有内容复制/粘贴到 ScrollView 或 StackView。