c# - uipopover controller is being dealloced monotouch -
i think, having issue uipopovercontroller
being deallocated before being dismissed, odd uipopovercontroller class variable. appreciated.
here error, getting
monotouch.foundation.monotouchexception: objective-c exception thrown. name: nsgenericexception reason: -[uipopovercontroller dealloc] reached while popover still visible. @ at (wrapper managed-to-native) monotouch.foundation.nsobject:monotouch_release_managed_ref (intptr) @ monotouch.foundation.nsobject.releasemanagedref () [0x00000] in /developer/monotouch/source/monotouch/src/foundation/nsobject.cs:99 @ monotouch.foundation.nsobject+nsobject_disposer.drain (monotouch.foundation.nsobject ctx) [0x00062] in /developer/monotouch/source/monotouch/src/shared/foundation/nsobject2.cs:602 @ at (wrapper managed-to-native) monotouch.uikit.uiapplication:uiapplicationmain (int,string[],intptr,intptr) @ monotouch.uikit.uiapplication.main (system.string[] args, system.string principalclassname, system.string delegateclassname) [0x0004c] in /developer/monotouch/source/monotouch/src/uikit/uiapplication.cs:38 @ lab_assistant.application.main (system.string[] args) [0x00008] in /working/lab_assistant/main.cs:17
and here class, working on
using system.drawing; using monotouch.foundation; using monotouch.uikit; namespace lab_assistant { [register("viewview")] public class viewview:uiview { public block _b { set; get;} public eventhandler _touched; private uiview _popviewtext; private uiviewcontroller _controller; private uipopovercontroller _popup; boolean edit; public viewview (block b,blockmanger.del themethod) { _b = b; this.frame = b._location; this.backgroundcolor = uicolor.white; this.addgesturerecognizer (new uilongpressgesturerecognizer (tapped)); themethod (_b,this); this.frame = new system.drawing.rectanglef(b._location.location, new system.drawing.sizef (b._location.width, b._location.height + 2)); } [export("tapped")] protected void tapped(uigesturerecognizer sender) { touchoccoured (); } public void edit() { uibutton btn = new uibutton (uibuttontype.roundedrect); _popviewtext = new uiview(new system.drawing.rectanglef(new system.drawing.pointf(0,0), new system.drawing.sizef(200,200))); _popviewtext.backgroundcolor = uicolor.darkgray; btn.hidden = false; btn.frame = new system.drawing.rectanglef(new system.drawing.pointf(0,31),new system.drawing.sizef(100,30)); btn.settitle ("remove", uicontrolstate.normal); uibutton btn2 = new uibutton (uibuttontype.roundedrect); btn2.hidden = false; btn2.frame = new system.drawing.rectanglef(new system.drawing.pointf(0,0),new system.drawing.sizef(100,30)); btn2.settitle ("resize", uicontrolstate.normal); _popviewtext.addsubview (btn); _popviewtext.addsubview (btn2); _controller = new uiviewcontroller (); _controller.add (_popviewtext); _popup = new uipopovercontroller(_controller); btn.touchupinside += (object sender, eventargs e) => { this.removefromsuperview(); edit = false; }; } public void editblock() { if (!edit) { edit = true; _popup.popovercontentsize = new sizef (200, 200); _popup.presentfromrect (new system.drawing.rectanglef (new pointf(0,0), new system.drawing.sizef (20, 20)), this, uipopoverarrowdirection.left, true); //_popviewtext = new uiview (rec); } } public void touchoccoured() { if(_touched != null) { this.edit (); this.editblock (); _touched (this, null); } } } }
thank help
i bet edit
called multiple times, resulting of multiple uipopovercontroller
being instantiated. if it's case, fix this:
public void edit () { if (_popup != null && _popup.popovervisible) { _popup.dismiss (false); _popup.dispose(); } //your code }
Comments
Post a Comment