Ячейки UITableView не отображают все данные - PullRequest
0 голосов
/ 18 ноября 2018

Заполнение UITableView первым из файла JSON.Кажется, что все загружается и нет сбоев, но ячейки таблицы не содержат все данные.Они обрезаны внизу.

HeroViewController

class HeroViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, WCSessionDelegate {

    // code

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

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

        let tableCell : HeroTableViewCell = tableView.dequeueReusableCell(withIdentifier: "MessageCell") as? HeroTableViewCell ?? HeroTableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "MessageCell")

        let row = indexPath.row
        let rowObj = messageObject[row]

        tableCell.one.text = rowObj.title as String?
        tableCell.two.text = rowObj.speaker as String?
        tableCell.three.text = rowObj.from as String?
        tableCell.four.text = rowObj.to as String?

        return tableCell
    }
}

1 Ответ

0 голосов
/ 18 ноября 2018

Ваши клетки, кажется, не имеют достаточной высоты.Вы можете установить его, перегрузив этот метод:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 100; //return the cell height you desire 
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...