xcode 表视图内部视图,内部视图控制器。最好的方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8796562/
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
Table view inside view, inside viewcontroller. Best way to do it?
提问by Alex Godbehere
I have a main home screen in my app which I am eventually hoping to contain a table view in the centre. When a button is pressed, the table view flips to a map view.
我的应用程序中有一个主主屏幕,我最终希望在它的中心包含一个表格视图。当按下按钮时,表格视图会翻转到地图视图。
I would do this as part of the main view, but I want the surrounding area to stay the same. I have dragged a view into the centre of the homepage view controller, and have set up my table view there. How do I access the data in this view?
我会将此作为主视图的一部分,但我希望周围区域保持不变。我将一个视图拖到主页视图控制器的中心,并在那里设置了我的表视图。如何访问此视图中的数据?
As far as I'm aware, there is no way of setting a tableviewcontroller to it. Any help would be greatly appreciated.
据我所知,无法为其设置 tableviewcontroller。任何帮助将不胜感激。
回答by Hyman Lawrence
You can make whatever View Controller is in charge of the views conform to UITableViewDelegate
and UITableViewDataSource
protocols in your header (.h) file:
你可以做任何视图控制器负责的意见,顺应UITableViewDelegate
和UITableViewDataSource
协议,在头文件(.h):
@interface YourViewControllerClass : UIViewController <UITableViewDelegate, UITableViewDataSource>
@interface YourViewControllerClass : UIViewController <UITableViewDelegate, UITableViewDataSource>
And then implement the appropriate methods in your implementation (.m) file.
然后在您的实现 (.m) 文件中实现适当的方法。
If you're using IB, drag the TableView's datasource and delegate outlets to your view controller subclass.
如果您使用的是 IB,请将 TableView 的数据源和委托出口拖到您的视图控制器子类中。