Sunday, 15 July 2012

ipad - Monotouch Crash: Replace UINavigationController A with B and Push UiViewControllers on B -



ipad - Monotouch Crash: Replace UINavigationController A with B and Push UiViewControllers on B -

we have been using xamarin while , causing weird crash while developing latest ipad app. next problem:

the ipad app uses story board 2 navigation controllers (say , b) each has rootviewcontroller (say a1 , b1), default navcontroller , showed on app start up. there 2 buttons on a1 , pressing button 1 loads navcontroller b.here steps code execute when button 1 on navcontroller clicked.

in button event handler , phone call public function in appdelegate following:

get storyboard id , instantiate navcontroller b using storyboard.instantiateviewcontroller. remove navcontroller superview (using uiview.view.removesuperview()) assign above reference of b appdelegate window's root view controller (which loads rootview controller b1 of navcontroller b).

it works fine till above step (i can see rootviewcontroller's uiview load on ipad).

the next step trying force uiviewcontroller after instantiating it.(because target 2 show sec screen in hierarchy) (storyboard.instantiateviewcontroller(identifier).this should ideally show me pushed view controller.but app crashes after step.!! weird!!!!. next simplified code:

public void setnavcontrollerb(uinavigationcontroller nava, uistoryboard storyboard) { nava.view.removefromsuperview(); this.window.rootviewcontroller = (uinavigationcontroller)storyboard.instantiateviewcontroller("vc0"); // 'vc0' identifier navigationcontroller b rootviewcontroller "vc1" // works great till above step uiviewcontroller vc2 = (uiviewcontroller)storyboard.instantiateviewcontroller("vc2"); ((uinavigationcontroller)this.window.rootviewcontroller).pushviewcontroller(vc2, true); //the above executes out exception, crashes later. }

pleaseeeee help!!!!!!

if modifying stack in uinavigationcontroller beyond force or pop, need replace entire stack of controllers:

mynavcontroller.setviewcontrollers(new uiviewcontroller[] { controller1, controller2 }, true);

if seek force or pop before previous force or pop completes, crash , warning in console output.

ps - don't think should need phone call removefromsuperview anywhere in situation, should modify uinavigationcontroller's stack or replace rootviewcontroller on window.

ipad uinavigationcontroller monotouch uistoryboard

No comments:

Post a Comment