简体   繁体   English

哪种方法符合UITableView协议?

[英]Which is the good way to conforms to UITableView protocols?

I am following this guideline to implement UITableView protocols. 我正在遵循准则来实现UITableView协议。 But right now, it's showing me an error, what I am doing wrong? 但是现在,它向我显示了一个错误,我在做什么错?

'RequestsViewController' does not conform to protocol 'UITableViewDataSource'. 'RequestsViewController'不符合协议'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) {

    }
}

CHANGE THIS 改变这个

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

TO: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这是将协议添加到我所连接的类的好方法吗? - Is this a good way to add protocols to a class I'm hooking in? 检测 UITableView 滚动的方式 - Detecting which way an UITableView is scrolling 如果我的课程符合具有相同属性的两个协议,将会怎样? - What will happen if my class conforms to two protocols having same property? 如何快速确定一类符合哪些协议? - How do I determine what protocols a class conforms to in swift? 实现符合键值观察的纯数据对象的最简单方法是什么? - What's the most *simple* way to implement a plain data object which conforms key-value-observing? 如何知道UITableView以哪种方式滚动 - How to know in which way UITableView is being scrolled 当数据对象符合NSCoding时,UITableView不显示新条目 - UITableView does not show new entries when data object conforms to NSCoding 在 Swift 中,如何声明符合一个或多个协议的特定类型的变量? - In Swift, how can I declare a variable of a specific type that conforms to one or more protocols? 我的班级符合两个协议 - 如何为每个协议设置不同的委托? - My class conforms to two protocols - how can I set different delegates to each of them? 优秀的UITableView设计画廊 - Gallery of good UITableView designs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM