ios - 未调用 UITableview 委托(delegate)

标签 ios objective-c uitableview

  1. 我已将表格 View 拖到 View Controller 中。
  2. 我已经为表创建了一个导出属性。

    @property(强,非原子)IBOutlet UITableView *tableView;

  3. 我已在界面中添加了委托(delegate)

    UITableViewDelegate

    4.将代表注册为:
    tableView.delegate=self;

并添加了表格 View 的所有功能,这些功能以前通常有效:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

还有其他的。 这些函数在启动时没有被调用。

我在这里缺少什么?

最佳答案

您缺少 tableView 的数据源。这些方法出现在数据源上,而不是委托(delegate)上。

也设置tableView.dataSource=self;,然后就可以开始了。

UITableView 有两个委托(delegate) delegatedataSource,因为它们处理不同的焦点区域。

关于ios - 未调用 UITableview 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21854020/

相关文章:

ios - 在 uitableview 单元格内为自定义 View 设置委托(delegate)

iOS UITableView 在模式关闭后不再调用委托(delegate)

iOS - 如何使 UICollectionViewCell 根据其内容调整其高度? (包含一个 UITableView)

ios - 是否可以使用从单个模态视图 Controller 返回到同一源 View Controller 的多个实例之一的展开转场?

objective-c - 归档静态库并获取源代码的可能性?

iOS UITableViewCell 与带有动态内容的 ScrollView

ios - 与 Interface Builder 连接,但 UITableView 为零?

iphone - 使用 CMMotionManager iPhone 的生涩 Action

iOS 8 : Remove Underline from UITableViewRowAction

ios - 当应用程序进入前台时获取待处理通知