xcode - UITableViewCell variables ni? -
i have correctly setup tableview using nib. register nib , identifier. somehow, getting nil in code here:
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = gallerytable.dequeuereusablecellwithidentifier("gallerycustomcell", forindexpath: indexpath) as! gallerycell
it takes me custom cell created , telling me every variable nil. have reconnected outlets , still receive errors.
in custom cell, crashes here:
override func awakefromnib() { super.awakefromnib() // initialization code self.backgroundcolor = uicolor.whitecolor() var tapphotoaction = uitapgesturerecognizer(target: self, action: selector("phototap:")) tapphotoaction.delegate = self tapphotoaction.cancelstouchesinview = false galleryphoto.addgesturerecognizer(tapphotoaction)
any thoughts on why happen @ all? saying galleryphoto nil, should not be. have outlet connected. also, happens on simulator, not on real device.
edit:
i not using storyboard, xib. have following code not using registerclass.
gallerycellloader = uinib(nibname: "gallerycell", bundle: nil) gallerytable.registernib(gallerycellloader, forcellreuseidentifier: "gallerycustomcell")
try delete
self.tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "gallerycustomcell")
then click tableview storyboard + ctrl , , drag line view controller , register table view. view controller should show
@iboutlet weak var tableview: uitableview!
( should use
class viewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource
in view controller have table view, click tableview in storyboard + ctrl , drag view controller click delegate , datasource )
then try run code again.
Comments
Post a Comment