ios - UITableViewCell not being called correctly -
i have cell class below:
class documentpartcell: uitableviewcell { @iboutlet weak var documentparttitle: uilabel! @iboutlet weak var documentpartnumber: uilabel! @iboutlet weak var documentpartprogress: uilabel! var documentpart: documentpart? { didset { if let documentpart = documentpart { self.documentparttitle.text = documentpart.title self.documentpartnumber.text = "\(documentpart.partnumber)" } } } } and can see, documentpart contains data.
if understand correctly, didset should input data documentpart documentparttitle , documentpartnumber.
in cellforrowindexpath following:
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let documentpartcell = tableview.dequeuereusablecellwithidentifier("documentpartcell", forindexpath: indexpath) as! documentpartcell return documentpartcell } however, when tableview showed on uiviewcontroller, doesn't trigger didset function here. set break point in middle of didset method.but hits cellforrowatindexpath function. doing wrong? i'm trying delegate jobs cell class input values in uilabel.
your cellforrowatindexpath should that:
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let documentpartcell = tableview.dequeuereusablecellwithidentifier("documentpartcell", forindexpath: indexpath) as! documentpartcell documentpartcell.documentpart = documentpartcommingfromthedatasource return documentpartcell }
Comments
Post a Comment