Monday, 15 February 2010

ios5 - Blank view in root controller when extending UINavigationController on iOS 5, but working on iOS 6 -



ios5 - Blank view in root controller when extending UINavigationController on iOS 5, but working on iOS 6 -

i found unusual behavior when extending (inheriting from) uinavigationcontroller. consider following:

public class mynavigationcontroller : uinavigationcontroller { public mynavigationcontroller(uiviewcontroller viewrootcontroller) : base(viewrootcontroller) { allnavigationcontrollers.add(this); } } ... window.rootviewcontroller = new mynavigationcontroller(new anothercontroller());

this works on ios 6, shows blank view in ios 5 instead of showing anothercontroller's main view (loaded nib). in theory, phone call base(viewrootcontroller) should take care of this; , without inheritance, very strange.

here's workaround...

public class mynavigationcontroller : uinavigationcontroller { public mynavigationcontroller(uiviewcontroller viewrootcontroller) : base() { allnavigationcontrollers.add(this); this.viewcontrollers = new uiviewcontroller[]{viewrootcontroller}; } } ... window.rootviewcontroller = new mynavigationcontroller(new anothercontroller());

not pretty, works on ios 5 , 6.

why phone call base(viewrootcontroller) not working when inheriting when don't?

(btw, not sure if issue specific monotouch (now xamarin.ios), or reproducible equivalent objective-c code).

ios5 ios6 monotouch

No comments:

Post a Comment