-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