ios - 如何使用 UITableView

标签 ios xcode uitableview

我在简单 View 中得到了UITableView,它由UIViewController控制

我实现了标准 UITableViewController 中的方法:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

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

但它不起作用。表格中没有显示任何内容

如何将数据上传到这个 UITableView?

最佳答案

  • 您是否设置了 UITableView 的数据源属性?指向你的UIViewController
  • 声明您的 Controller 遵守 <UITableViewDataSource>协议(protocol),通过这种方式,如果您错过了实现某些必需的方法,您将收到一些警告。

您是否尝试使用 UIViewController代替 UITableViewController ?为什么? (正如Damien所说,这应该是第一个问题)。

关于ios - 如何使用 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9241393/

相关文章:

ios - 关于Objective-C或iOS中的内存管理

xcode - 使用名称和密码对 Github 远程进行身份验证

ios - switch in a tableview with UserDefaults, several is activated by itself

ios - TableView 问题,indexPath 为零

ios - '-[__NSCFNumber 行] : unrecognized selector sent to instance 0xb416910'

ios - 如何设计自定义导航栏

ios - 切换到另一个 View 时隐藏键盘

ios - 强制 App 导航到 App DidBecomeActive 中的特定 View

swift - 从右向左连续,无需推送或呈现 ViewController

ios - 如何在 Objective-C 和 Swift 项目中使用 RxSwift?