ios - Eureka Forms Image check row update cell on scroll -
i have strange bug eureka forms. there 3 image check rows,
1) speedex 2) post 3) pickup when user selects 1 of them, there text on end of form being updated. issue when user selects 1 of them, text showing correct text. when user scrolls , down form, text blank. means table reloads data , lose choice of user.
the following code i've done till now. first create class of imagecheckrow.
public final class imagecheckrow<t: equatable>: row<imagecheckcell<t>>, selectablerowtype, rowtype { public var selectablevalue: t? required public init(tag: string?) { super.init(tag: tag) displayvaluefor = nil } } public class imagecheckcell<t: equatable> : cell<t>, celltype { required public init(style: uitableviewcellstyle, reuseidentifier: string?) { super.init(style: style, reuseidentifier: reuseidentifier) } required public init?(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } lazy public var trueimage: uiimage = { return uiimage(named: "selected")! }() lazy public var falseimage: uiimage = { return uiimage(named: "unselected")! }() public override func update() { super.update() accessorytype = .none imageview?.image = row.value != nil ? trueimage : falseimage oroi = row.value != nil ? 1 : 0 } public override func setup() { super.setup() textlabel?.numberoflines = 0 } public override func didselect() { row.reload() row.select() row.deselect() } } then sections. var text = "" var discount = ""
+++ selectablesection<imagecheckrow<string>>("delivery selection", selectiontype: .singleselection(enabledeselection: true)) { section in section.tag = "deliveryselection" } <<< imagecheckrow<string>("speedex"){ $0.title = dtext $0.selectablevalue = "" $0.value = nil }.cellsetup { cell, _ in cell.trueimage = uiimage(named: "selectedrectangle")! cell.falseimage = uiimage(named: "unselectedrectangle")! }.oncellselection({ (cell, row) in row.title = "speedex" row.selectablevalue = "selectedspeedex" }).cellupdate({ (cell, row) in self.text = "speedex:" if self.sinolo1 < 100.0 { self.discount = "3.00€" }else{ self.discount = "--" } print("here speedex") let section: section? = self.form.sectionby(tag: "summary") section?.reload() }) <<< imagecheckrow<string>("post"){ $0.title = "post" $0.selectablevalue = "" $0.value = nil }.cellsetup { cell, _ in cell.trueimage = uiimage(named: "selectedrectangle")! cell.falseimage = uiimage(named: "unselectedrectangle")! }.oncellselection({ (cell, row) in row.title = "post" row.selectablevalue = "selectedpost" }).cellupdate({ (cell, row) in print("here paradosi") self.text = "post:" self.discount= "6.00€" let section: section? = self.form.sectionby(tag: "summary") section?.reload() }) <<< imagecheckrow<string>("pickup"){ $0.title = "pick up" $0.selectablevalue = "" $0.value = nil }.cellsetup { cell, _ in cell.trueimage = uiimage(named: "selectedrectangle")! cell.falseimage = uiimage(named: "unselectedrectangle")! }.oncellselection({ (cell, row) in row.title = "pickup" row.selectablevalue = "selectedpickup" }).cellupdate({ (cell, row) in print("here pickup") self.text = "pick up:" self.discount= "--" let section: section? = self.form.sectionby(tag: "summary") section?.reload() }) and final section displays selected row above.
+++ section("summary") <<< summarypuchaserow().cellupdate({ (cell, row) in cell.merikosinolo.text = "\(self.realmfunctions.getamount())€" cell.onomaepilogis.text = self.text print(self.text) cell.discount.text = self.discount }) the strings "text" , "discount" initated outside "viewdidload".
any idea why lose selection when scroll form?
Comments
Post a Comment