-1
问题:image of UITableViewCells that never display data without being selected.UITableView的数据显示古怪SWIFT 3.0
的问题是一致的就好了,即使禁止用户触摸交互仍然造成这一问题的出现。行应该有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!
}
我居然发现,在斯威夫特3和Xcode中8,表标题是导致该问题。我不完全确定它为什么只在运行时发生,并且在实际编辑过程中从未出现过,但是我避免使用表标题作为当前配置(iOS 10,Swift 3和Xcode 8)。 – Austin