storyboard - If I show a viewcontroller in iOS using instantiateViewControllerWithIdentifier i can not leave the view without crashing -


if show viewcontroller in ios using instantiateviewcontrollerwithidentifier, can not leave viewcontroller without crashing. view loads fine , performs tasks when try leave pushing button app crashes. because of state wrong or have made mistake?

code:

- (ibaction)push:(id)sender {      uistoryboard *mainstoryboard = [uistoryboard storyboardwithname:[[nsbundle mainbundle].infodictionary objectforkey:@"uimainstoryboardfile"] bundle:[nsbundle mainbundle]];     nslog(@"story: %@",mainstoryboard.description);      appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication] delegate];      listviewcontroller *controller = (listviewcontroller*)[mainstoryboard instantiateviewcontrollerwithidentifier: @"listid"];     appdelegate.window.rootviewcontroller = controller;  } 

you're changing applications root view controller result of pressing button on previous root view controller. that's not how navigation in ios app should done. instead, try embedding root view controller in uinavigationcontroller , push , pop view controllers through navigate around app.

if interface doesn't fit navigation paradigm, use presentviewcontroller:animated:completion:. regardless, should read view controller programming guide addresses best practices of displaying views.


Comments