Попытка установить высоту строки в tableView для ячеек - PullRequest
0 голосов
/ 11 сентября 2018

Я обновляю свое приложение, и я использовал этот метод в других областях приложения, и он работает, но по какой-то причине он не работает с tableView.

TableView находится внутриViewController (CurrencyViewController)

@IBOutlet weak var tableView: UITableView!

tableView.dataSource = self

extension CurrencyViewController: UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

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

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return currencies.count
    }

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

        let cell = tableView.dequeueReusableCell(withIdentifier: "currencyCell")! as! CurrencyTableViewCell

        cell.name.text = currencies[indexPath.row].currencyName
        cell.name.textColor = Styles.whiteColor()
        cell.symbol.text = currencies[indexPath.row].currencyCode
        cell.symbol.textColor = Styles.whiteColor()

        cell.backgroundColor = Styles.mainColor();

        return cell
    }
}

enter image description here

Сам TableView работает, он просто не обновляет высоту строки.

Что-то изменилось с обновлением Swift?

Ответы [ 2 ]

0 голосов
/ 11 сентября 2018

Если в ИБ подключено dataSourcedelegate), удалить

tableView.dataSource = self

Вы также должны принять UITableViewDelegate в расширении, подключения делегата недостаточно

extension CurrencyViewController: UITableViewDataSource, UITableViewDelegate {
0 голосов
/ 11 сентября 2018

Вы, кажется, не соответствовали UITableViewDelegate?

extension CurrencyViewController: UITableViewDataSource, UITableViewDelegate
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...