c# - Xamarin DialogViewController not disposed when Root is set -
i'm having weird problem. i'm using subclasses of dialogviewcontroller multi-page interview. each page presents number of fields can edited, , hitting save in upper right pushes next page onto navigationcontroller. seemed working fine, became apparent backing out , repeating interview leaks memory. created simple test case cleans button event navigation item. in example, dispose called when second controller popped, if don't set root other null (i.e. works expected if comment root = ... line). here's code. please tell me i'm missing stupid.
public class testviewcontroller : dialogviewcontroller { int mpage; public testviewcontroller (int page) : base (null, true) { mpage = page; root = new rootelement ("testing") { new section () { new stringelement ("page: " + mpage) } }; } public override void viewdidload () { base.viewdidload (); navigationitem.rightbarbuttonitem = new uibarbuttonitem (uibarbuttonsystemitem.play); } public override void viewwillappear (bool animated) { base.viewwillappear (animated); navigationitem.rightbarbuttonitem.clicked += onclicked; } public override void viewdiddisappear (bool animated) { base.viewdiddisappear (animated); navigationitem.rightbarbuttonitem.clicked -= onclicked; } private void onclicked(object sender, eventargs e) { navigationcontroller.pushviewcontroller(new testviewcontroller(mpage + 1), true); } protected override void dispose (bool disposing) { base.dispose (disposing); } }
Comments
Post a Comment