I cannot understand why this user cell is not displayed.
I have a custom cell configured in a storyboard (no nib). I have a text box and 2 shortcuts that are zero when I try to access them in a custom cell class. I'm pretty sure everything is connected correctly, but still getting zero.
I selected the table cell in the storyboard and set the Custom Class to TimesheetTableViewCell I also controlled the click on the table and set the data source and delegate as TimesheetViewController
My custom cell class:
import UIKit class TimesheetTableViewCell: UITableViewCell { @IBOutlet var duration: UITextField! @IBOutlet var taskName: UILabel! @IBOutlet var taskNotes: UILabel! required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override init?(style: UITableViewCellStyle, reuseIdentifier: String!) { super.init(style: style, reuseIdentifier: reuseIdentifier) println("Cell initialised")
My controller:
class TimesheetViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{ @IBOutlet var timesheetTable: UITableView! var items = ["Item 1", "Item2", "Item3", "Item4"] override func viewDidLoad() { super.viewDidLoad() self.timesheetTable.registerClass(TimesheetTableViewCell.self, forCellReuseIdentifier: "TimesheetCell") } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("TimesheetCell", forIndexPath: indexPath) as TimesheetTableViewCell println(items[indexPath.row])
source share