ios - 哪个是符合 UITableView 协议(protocol)的好方法?

标签 ios swift uitableview

我正在关注 this实现 UITableView 协议(protocol)的指南。但是现在,它向我显示错误,我做错了什么?

'RequestsViewController' does not conform to protocol 'UITableViewDataSource'.


class RequestsViewController: UIViewController {
    ...
    ...
}

extension RequestsViewController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return arrayRequests.count
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell {
        let cell:RequestsTableViewCell = (tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as! RequestsTableViewCell)
        //Doing some assignments.
        return cell
    }
}

extension RequestsViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    }
}

最佳答案

改变这个

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell

收件人:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

关于ios - 哪个是符合 UITableView 协议(protocol)的好方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44941062/

相关文章:

ios - CLLocationManager didUpdateLocations 未被调用

ios - 如何从Firebase以值的降序获取数据?

ios - UITableView 滚动时动态加载内容

ios - 估计信标 IOS - 仅使用 UUID 值搜索信标

IOS:展开图像查看全屏

ios - 在哪些队列中执行 Collection View 的委托(delegate)/数据源方法?

swift - Xcode 9 : SKEditorReference doesn't allow animations?

swift - 访问另一个 View Controller 中的变量 - Xcode 8.0 Swift 3.0

ios - 'didSet' 数组中的某些元素 - Swift

ios - 如何使用自动布局正确约束 UITableView