Custom Cell in UITableView giving error Swift -
i totally stuck. iv searched on place , cant seem figure out why maintain getting error - , create worse, error log shows (lldb)
i'm trying show custom cells in table. each cell has main label called lblroutenumber, , there 2 labels on either side, lblleftstation , lblrightstation.
where register custom cell class table view:
self.tblmain.registerclass(customtableviewcell.classforcoder(), forcellreuseidentifier: "celltemplate")
my cell creator method:
func tableview(tableview: uitableview!, cellforrowatindexpath indexpath: nsindexpath!) -> uitableviewcell! { var cell = tblmain.dequeuereusablecellwithidentifier("celltemplate", forindexpath: indexpath) customtableviewcell cell.lblroutenumber.text = "routing" cell.lblleftstation.text = "left" cell.lblrightstation.text = "right" homecoming cell } and custom cell class:
class customtableviewcell: uitableviewcell { @iboutlet var lblroutenumber : uilabel @iboutlet var lblleftstation : uilabel @iboutlet var lblrightstation : uilabel init(style: uitableviewcellstyle, reuseidentifier: string) { super.init(style: style, reuseidentifier: reuseidentifier) } override func awakefromnib() { super.awakefromnib() // initialization code } override func setselected(selected: bool, animated: bool) { super.setselected(selected, animated: animated) // configure view selected state } the app crashes on line
var cell = tblmain.dequeuereusablecellwithidentifier("celltemplate", forindexpath: indexpath) customtableviewcell
and if seek assign label within, cannot disclose optional.none error.
delete next code customtableviewcell
init(style: uitableviewcellstyle, reuseidentifier: string) { super.init(style: style, reuseidentifier: reuseidentifier) } then answered here question
custom uitableviewcell shows "fatal error: can't disclose optional.none" issue in swift
uitableview swift xcode6
No comments:
Post a Comment