// cellule personnalisée dans un fichier rapide
IBoutlet est nul dans ma cellule de table personnalisée?
import UIKit
class CardTableViewCell: UITableViewCell {
@IBOutlet weak var elapsedTime: UILabel!
@IBOutlet weak var todo: UILabel!
@IBOutlet weak var startAndStop: UIView!
@IBOutlet weak var progress: UIView!
@IBOutlet weak var cardView: UIView!
}
// contrôleur de vue Tableau personnalisé dans un autre fichier rapide
import UIKit
class CardFeedTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(CardTableViewCell.self, forCellReuseIdentifier: "cardCell")
tableView.delegate = self
tableView.dataSource = self
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 3
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: CardTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "cardCell", for: indexPath) as! CardTableViewCell
cell.todo.text = "study"
return cell
}
running the app triggers a error
Je ne sais pas pourquoi toutes les propriétés dans la cellule de mon tableau est nulle, quand je cours l'application.
Si vous n'avez pas utilisé xib, vous devez supprimer le registre de la ligne de vue ne charge, sinon, vous devez utiliser nib cellulaire registre pour identifier tableView.register (UINib ... ", pourCellReuseIdentifier: CardTableViewCell.self) –
em ~, pouvez-vous me donner plus de détails? Je ne sais toujours pas pourquoi il devrait être comme ça? T_T – cary