iphone - Retrieve values from UITextFields inside custom UITableViewCell -
i swear i've searched entire google database possible solution i'm still stuck on issue :)
basically, have 12 rows in database table generate custom uitableviewcell 4 uitextfields inside. table columns (sqlite)
entryfieldid number description text fieldtype text
now want each uitableviewcell
tag entryfieldid
above can refer later storing in table. table looks this.
orderid number entryfieldid number value1 text value2 text value3 text value4 text
the 4 value* fields 4 uitextfields
inside each uiviewcell
.
hopefully makes sense far :)
now inside tableviewsource have code:
protected list<infocapturetableviewgroup> _tableitems; protected string _customcellidentifier = "infocapturefield"; protected dictionary<int, infocapturetableviewcell> _cellcontrollers = new dictionary<int, infocapturetableviewcell>(); public infocapturetablesource (list<infocapturetableviewgroup> items) { this._tableitems = items; } /// <summary> /// called tableview determine how many sections(groups) there are. /// </summary> public override int numberofsections (uitableview tableview) { return this._tableitems.count; } /// <summary> /// called tableview determine how many cells create particular section. /// </summary> public override int rowsinsection (uitableview tableview, int section) { return this._tableitems[section].items.count; } /// <summary> /// called tableview retrieve header text particular section(group) /// </summary> public override string titleforheader (uitableview tableview, int section) { return this._tableitems[section].name; } /// <summary> /// called tableview retrieve footer text particular section(group) /// </summary> public override string titleforfooter (uitableview tableview, int section) { return this._tableitems[section].footer; } /// <summary> /// called tableview retreive height of row particular section , row /// </summary> public override float getheightforrow (uitableview tableview, monotouch.foundation.nsindexpath indexpath) { return 44f; } public override uitableviewcell getcell (uitableview tableview, monotouch.foundation.nsindexpath indexpath) { // there way not reuse cells? there's ever going 12 of them uitableviewcell cell = tableview.dequeuereusablecell (this._customcellidentifier); infocapturetableviewcell customcellcontroller = null; infocapturefield item = this._tableitems[indexpath.section].items[indexpath.row]; //---- if there no cells reuse, create new 1 if (cell == null) { customcellcontroller = new infocapturetableviewcell(); // retrieve cell our custom cell controller cell = customcellcontroller.cell; // disable selection cell.selectionstyle = uitableviewcellselectionstyle.none; // i'd use entryfieldid cell.tag = environment.tickcount; // store our controller unique id gave our cell this._cellcontrollers.add (cell.tag, customcellcontroller); } else { // retrieve our controller via it's unique id customcellcontroller = this._cellcontrollers[cell.tag]; } //---- return custom cell return cell; }
the code above doesn't make sense me, copied monotouch example. understand cells reused i'd avoid can use entryfieldid custom cell's tag property , can loop through rows of uitableview (which understand might not possible).
so, if shed light on current approach, whether it's feasible or not, or whether should looking @ re-implementing whole thing all-together.
you big favor if not consider uitableviewcells building blocks application hold state, are: transient objects created , destroyed on demand rendering information.
if make leap in thinking uitableviewcell, realize whatever happens on cell in terms of changes particular control or data structures, needs reflected elsewhere.
the first problem have code using cells way intended used: reusing existing cell queue, decide not wanted , trying use different lookup system. why approach wont work.
you have few options:
(a) use uitableviewcells way supposed used. annoying, there tools make lot simpler, things monotouch.dialog or can check blog entry on design patterns uitableviewcells:
http://tirania.org/monomac/archive/2011/jan-18.html
(b) instead of reusing same cell identifier in code, use 1 cell identifier each row. force uitableview create new cells, 1 per row want later up. if going have 12 rows, should no problem.
Comments
Post a Comment