I got this error message when trying to addSubView()
into UITableViewCell
Error message
2015-05-18 11:26:46.048 xxxxx[1128:437863] * Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-3347.44/UITableView.m:6245 2015-05-18 11:26:46.053 DateTick[1128:437863] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier AgeCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' *** First throw call stack: (0x1856982d8 0x196ebc0e4 0x185698198 0x18654ced4 0x18a251e84 0x100094c20 0x100095070 0x18a3d9a68 0x18a3cd890 0x18a1b9268 0x18a0d5760 0x189a1de1c 0x189a18884 0x189a18728 0x189a17ebc 0x189a17c3c 0x189a11364 0x1856502a4 0x18564d230 0x18564d610 0x1855792d4 0x18ed8f6fc 0x18a13efac 0x1000c0a9c 0x19753aa08) libc++abi.dylib: terminating with uncaught exception of type NSException
I already declared AgeCell
inside UITableViewCell
identifier
My code:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("AgeCell", forIndexPath: indexPath) as! UITableViewCell //1
let slider = RangeSlider(frame:cell.bounds)
slider.minimumValue = 1;
slider.selectedMinimumValue = 2;
slider.maximumValue = 10;
slider.selectedMaximumValue = 8;
slider.minimumRange = 2;
slider.addTarget(self, action:"updateRangeLabel", forControlEvents:UIControlEvents.ValueChanged)
cell.addSubview(slider)
return cell
}
P.S: BTW my UITableViewController
is a static cell, not a dynamic cell.