i'm using zxing mobilescanner lib xamarin project ios (monotouch). set scanning, working fine, reading qrcode , having correct result. after reading qrcode want show viewcontroller. set property in second controller result scanning , want show controller.
the second view not shown on screen. no errors, no feedback, not shown. guess, mobilescanner builds own view (which can seen in source of lib) , adds navigationcontroller - , causes controller stay "behind". testing redirecting controller on button clicks working fine. tried "dispose" view calling scanner.cancel(), results in
warning: attempt dismiss view controller <uinavigationcontroller: 0x19a0c60> while presentation or dismiss in progress!
here code, on how display view appreciated.
public override void viewdidload () { base.viewdidload (); // perform additional setup after loading view, typically nib. scanner = new mobilebarcodescanner(this.navigationcontroller); this.btnscan.touchupinside += (sender, e) => { //tell our scanner use default overlay scanner.usecustomoverlay = false; //we can customize top , bottom text of default overlay scanner.toptext = "ticket vor den scanner halten"; scanner.bottomtext = "code wird automatisch eingelesen"; //start scanning scanner.scan ().continuewith((t) => { //our scanning finished callback if (t.status == system.threading.tasks.taskstatus.rantocompletion){ string msg = ""; zxing.result result = t.result; if (result != null && !string.isnullorempty (result.text)) { scanner.cancel(); if(this.ticketscreen == null) { this.ticketscreen = new ticketscreen(); } this.ticketscreen.ticketurl = result.text; this.navigationcontroller.pushviewcontroller(this.ticketscreen, true); } else { msg = "code nicht erkannt!"; this.invokeonmainthread(() => { var av = new uialertview("fehler!", msg, null, "ok", null); av.show(); }); } } }); }; }
i use this.invokeonmainthread(() , works fine in code. solution is:
public override void viewdidload () { base.viewdidload ();
// perform additional setup after loading view, typically nib. scanner = new mobilebarcodescanner(this.navigationcontroller); this.btnscan.touchupinside += (sender, e) => { //tell our scanner use default overlay scanner.usecustomoverlay = false; //we can customize top , bottom text of default overlay scanner.toptext = "ticket vor den scanner halten"; scanner.bottomtext = "code wird automatisch eingelesen"; //start scanning scanner.scan ().continuewith((t) => { //our scanning finished callback if (t.status == system.threading.tasks.taskstatus.rantocompletion){ string msg = ""; zxing.result result = t.result; if (result != null && !string.isnullorempty (result.text)) { scanner.cancel(); this.invokeonmainthread(() => { if(this.ticketscreen == null) { this.ticketscreen = new ticketscreen(); } this.ticketscreen.ticketurl = result.text; this.navigationcontroller.pushviewcontroller(this.ticketscreen, true); }); } else { msg = "code nicht erkannt!"; this.invokeonmainthread(() => { var av = new uialertview("fehler!", msg, null, "ok", null); av.show(); }); } } }); }; }
Comments
Post a Comment