UITableView显示数据奇怪的快速3.0

时间:2016-10-04 23:11:27

标签: uitableview swift3 ios10

问题:image of UITableViewCells that never display data without being selected.

问题非常一致,甚至禁用用户触摸交互仍然会导致出现此问题。行应该有3个子行,但只显示该部分的末尾(以及标题,如图中所示)。

此表视图的代码:

import UIKit

class HistoryViewController : UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet var tableview: UITableView!

    var data = LocalizedData.localizedData
    let cellReuseIdentifier = "tableCell"

    override func viewDidLoad() {
        super.viewDidLoad()

        tableview.delegate = self
        tableview.dataSource = self
        //tableview.allowsSelection = true
        tableview.allowsMultipleSelection = true

        if AppDelegate.debug {
            print("HistoryViewLoaded")
        }
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        tableview.reloadData()
    }

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

    func tableView(_ tableView:UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as! HistoryViewTableCell

        if !AppDelegate.device.isEqual(to: 4.0) {
             cell.textLabel?.text = "Entry " + (indexPath.item + 1).description
        }

        if data.getMatchDataCount() > 0 {
            cell.matchNumb?.text = data.getMatchTest(matchNumber: indexPath.item)[1].description
            cell.teamNumb?.text = data.getMatchTest(matchNumber:indexPath.item)[0].description
        }

        return cell
    }
}

class HistoryViewTableCell: UITableViewCell {

    @IBOutlet weak var teamNumb: UILabel!
    @IBOutlet weak var matchNumb: UILabel!
    @IBOutlet weak var matchPoints: UILabel!

}

1 个答案:

答案 0 :(得分:0)

你应该尝试打印teamNumb& amp; matchNumb,根据图片看起来标签在这里,但有一些布局问题。

print(matchNumb.frame)
print(teamNumb.frame)

您是否在Swift 2.2,Swift 2.3或之前使用过代码?

我有一个类似的问题,我的单元格没有动画'cellForRowAt'函数,因为我将我的项目转换为Swift 3,并且我发送到main修复了它。 当我调试时,这一行已经在主线程中了。

我想你可以试试:

DispatchQueue.main.async {
    // Set cell.numb.text here..
}