【问题标题】:How to display data in a table inside a subview如何在子视图内的表格中显示数据
【发布时间】:2014-11-25 13:38:05
【问题描述】:

我有一个 ViewController,我在其中放置了另一个小的 UIView,其中我放置了一个 TableView,但不知道如何在此表中显示数组中的数据,可能会有所帮助。

我尝试把 UITableViewDelegate、UITableViewDataSource 和方法 numberOfSectionsInTableView、numberOfRowsInSection、numberOfRowsInSection

没有用

【问题讨论】:

  • 您是否将 tableView 的委托/数据源连接到实现这些方法的类/类?
  • 对不起,我不知道该怎么做
  • 将它添加到另一个视图中不会改变 tableView 的行为。也许您对 tableViewController 感到困惑,这是另一回事。您只需要创建tableView的一个属性,设置委托和数据源并实现所需的方法。
  • 成功了,非常感谢

标签: ios objective-c uitableview uiview xcode5


【解决方案1】:

您缺少的主要方法是: cellForRowAtIndexPath 用于显示单元格并调整其信息...并确保您在主队列中的异步调度中调用显示视图。

【讨论】:

  • 我有但不工作,我不知道如何将de tableView连接到delegate/dataSource
【解决方案2】:

先设置UITableViewDelegate、UITableViewDataSource。

然后使用下面的方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return generateImageOptionsArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
}

希望对你有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多