2
,一切工作正常,除了最後一行,我試圖表明的tableView
在實時取景不起作用:PlaygroundPage.current.liveView = controller
顯示的TableView爲iPad
我想不出什麼我越來越錯了嗎?
import UIKit
import PlaygroundSupport
import Foundation
class TableViewController: UITableViewController {
let tableData = ["Matthew", "Mark", "Luke", "John"]
override func viewDidLoad() {
super.viewDidLoad()
print("Hello Matt")
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
cell.textLabel?.text = tableData[indexPath.row]
return cell
}
}
let controller = TableViewController()
PlaygroundPage.current.liveView = controller
登記表視圖細胞類什麼不起作用?有錯誤嗎?怎麼了? –
@JackLawrence akosma釘了它,欣賞你看着它,並檢查什麼是錯的 – SRMR
https://gist.github.com/watert/13c38d269ea15aa8360f – StackUnderflow