ios - UILabels in Custom UITableViewCell not rendering on screen -
hello , thank help. have custom uitableviewcell , controller of class written in swift. of init functions being called on creation of cell on inspection in debugger of lables , 1 image view have added content view have frame of 0.
here file containing tableview:
class searchesmainviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet var contenttableview: uitableview? var tableviewdata = searchesmaintableviewdata() required init(coder adecoder: nscoder) { super.init(coder: adecoder) } internal override init(nibname nibnameornil: string?, bundle nibbundleornil: nsbundle?) { super.init(nibname: nibnameornil, bundle: nibbundleornil) } override func viewdidload(){ super.viewdidload() self.navigationitem.title = "search" var nib = uinib(nibname: "singlesearchtableviewcell", bundle: nil) contenttableview?.registernib(nib, forcellreuseidentifier: singlesearchtableviewcellcontroller.reuseid()) } func numberofsectionsintableview(tableview: uitableview) -> int { return tableviewdata.numberofsectionsintableview() } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return tableviewdata.numberofrowsintablesection(section) } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell{ var cell:singlesearchtableviewcellcontroller = tableview.dequeuereusablecellwithidentifier(singlesearchtableviewcellcontroller.reuseid()) singlesearchtableviewcellcontroller cell.formatcell() return cell } func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat { return 54.0 } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { tableview.deselectrowatindexpath(indexpath, animated: false) } func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? { return tableviewdata.headerviewforsection(section) } func tableview(tableview: uitableview, heightforheaderinsection section: int) -> cgfloat { return tableviewdata.heightfortableviewsectionheaders() } func tableview(tableview: uitableview, heightforfooterinsection section: int) -> cgfloat { return tableviewdata.heightfortableviewsectionfooters() } }
here controller cell:
class singlesearchtableviewcellcontroller : uitableviewcell { @iboutlet var datemonthlable : uilabel? @iboutlet var datedaylable : uilabel? @iboutlet var yearlable : uilabel? @iboutlet var makemodellable : uilabel? var search : search = search() class func reuseid() -> string{ return "singlesearchtableviewcell" } required init(coder adecoder: nscoder) { super.init() } override init(frame: cgrect) { super.init(frame: frame) } override init(style: uitableviewcellstyle, reuseidentifier: string?) { super.init(style: style, reuseidentifier: reuseidentifier) } override func awakefromnib() { super.awakefromnib() // initialization code } init(previoussearch s : search){ search = s super.init() } func formatcell(){ formatdatemonthlable() formatdatedaylable() formatyearrangelable() formatmakemodellable() } private func formatdatemonthlable(){ } private func formatdatedaylable(){ } private func formatyearrangelable(){ } private func formatmakemodellable(){ } }
and image of tableview cell in interface builder of bindings:
thanks lot sugestions or help, new both swift , interface builder. have nice day :)
edit actualy built code
it seams every other place use nibs there initwithnib or along lines, , there nothing tableview cells. think linking of data , view may off or missing something.
the problem init overrides in cell class. i'm not familiar swift, don't know why having in there nothing calls super causes subview not show. since you're not doing in methods (or awakefromnib either), should delete them. think fix problem (it did in tests).
Comments
Post a Comment