Sunday, 15 May 2011

ios - Present ViewController on UISplitViewNavigator's MasterViewController -



ios - Present ViewController on UISplitViewNavigator's MasterViewController -

i've created new xcode project using splitviewnavigator template. 1 of masterviewcontroller's navigationitems should nowadays configuration viewcontroller (fullscreen on iphone, popup on ipad).

this config controller has been created in separate storyboard (filter.storyboard). in storyboard dragged viewcontroller on stage , embedded in navigation controller (editor -> embed in -> navigation controller) because config consists of different screens user can go through. navigationcontroller has been given storyboard id "filternavcontroller".

i've done several times in other applications, work. unfortunately, can't working splitviewnavigator template.

here how seek open filter controller 1 time button has been tapped, nil special it;

uistoryboard *filterboard = [uistoryboard storyboardwithname:@"filter" bundle:nil]; uinavigationcontroller *filternavcontroller = [filterboard instantiateviewcontrollerwithidentifier:@"filternavcontroller"]; uiviewcontroller *vc = [filternavcontroller.viewcontrollers objectatindex:0]; [self.navigationcontroller presentviewcontroller:vc animated:yes completion:nil];

self masterviewcontroller.

from uneducated point of view, don't see reason why wouldn't work. said, in other (non splitviewnavigator template) applications. error message i'm getting following:

terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'application tried nowadays modally active controller <uinavigationcontroller: 0x7f9bab61a700>.'

no thought heck going on here cost me half day. interestingly, when create uiviewcontroller on filter.storyboard , set storyboardid, viewcontroller presented. however, need embedded in uinavigationcontroller.

any help highly appreciated!

for sakes of completeness, next method works nicely instantiating viewcontrollers storyboard.

instead of creating uinavigationcontroller on storyboard, create viewcontroller(s) , embed them in uinavigationcontroller on code.

uistoryboard *myboard = [uistoryboard storyboardwithname:@"mystoryboard" bundle:nil]; myviewcontroller *menucontroller = [myboard instantiateviewcontrollerwithidentifier:@"myviewcontroller"]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:mycontroller]; [self presentviewcontroller:navcontroller animated:yes completion:nil];

ios objective-c cocoa-touch uisplitviewcontroller

No comments:

Post a Comment