ios - Custom UITableViewCell, GetCell throws UnknownNSKeyException -
i have created custom uitableviewcontroller
, cell , source in project. controller , cell created iphone uiviewcontroller template got partial class paired xib file. have same setup working table , have followed same process (i think) create 1 why have no idea why i'm getting error.
this getcell
in tableviewsource
class
public override uitableviewcell getcell (uitableview tv, nsindexpath path) { mycell ocell; nsarray oviews; // ocell = tv.dequeuereusablecell ("mycell") mycell; // if (ocell == null) { oviews = nsbundle.mainbundle.loadnib ("mycell", tv, null); ocell = runtime.getnsobject (oviews.valueat (0)) mycell; } // ocell.updatewithdata (mydatacollection[path.row]); // return ocell; }
i exception on line tries load nib:
objective-c exception thrown. name: nsunknownkeyexception reason: [ setvalue:forunidentifiedkey:]: class not key value coding-compliant key lbl_address.
i'm thinking refers problem in ib have created cell interface lbl_address
uilabel inside uitableviewcell
. i'm trying play around things in ib can pretty infuriating if don't correctly first time round. recognise error , set me straight.
edit
in absence of finding answer have chosen avoid loading nib , have made following changes code:
new get cell
method in mytableviewsource
public override uitableviewcell getcell (uitableview tv, nsindexpath path) { mycell ocell; // ocell = tv.dequeuereusablecell ("mycell") mycell; // if (ocell == null) ocell = new mycell ("mycell"); // ocell.updatewithdata (mydatacollection[path.row]); // return ocell; }
new constructor mycell
public mycell (string sidentifier) : base (uitableviewcellstyle.default, sidentifier) { // set contents of cell in absence of loading nib txt_name = new uilabel () { font = uifont.systemfontofsize (15), textcolor = uicolor.lightgray }; img_profile = new uiimageview (); // // make sure add controls content view! contentview.add (txt_name); contentview.add (img_profile); }
hope helps out there :)
this due element has been removed previous connection outlet in xib still remains valid.
i try following steps.
open xib. right click on cell. if see yellow warning near key name, remove (x button).
let me know if fix problem.
Comments
Post a Comment