Last active
February 28, 2018 02:26
-
-
Save jkyin/ee18d61341a82f8f2b2ec1339d0fa4a3 to your computer and use it in GitHub Desktop.
crash code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
private lazy var hotStockTableView: UITableView = { | |
let tableView = UITableView() | |
print("hotStockTableView ======> \(tableView) \n") | |
tableView.delegate = self | |
tableView.dataSource = self | |
// Here cause crash. | |
tableView.tableFooterView = UIView() // if comment this line, everthing is ok. | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") | |
return tableView | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.addSubview(hotStockTableView) | |
hotStockTableView.frame = view.bounds | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
print("tableView =====> \(tableView) \n") | |
if tableView == hotStockTableView { | |
return 5 | |
} else { | |
return 0 | |
} | |
} | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
var cell = tableView.dequeueReusableCell(withIdentifier: "cell") | |
if cell == nil { | |
cell = UITableViewCell(style: .default, reuseIdentifier: "cell") | |
} | |
cell?.textLabel?.text = "\(indexPath.row)" | |
return cell! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment