ios - Error when presenting different storyboard programmatically -
i have app 2 storyboards. 1 of them main app stuff, , 1 setup storyboard set user profile. right now, have set main interface setup.storyboard
. in first view controller in storyboard, in -viewwillappear:animated
method, checks nsuserdefault
see if setup complete. if is, execute code.
- (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; if ([[nsuserdefaults standarduserdefaults] boolforkey:@"userhascompletedsetup"]) { uistoryboard *sb = [uistoryboard storyboardwithname:@"main" bundle:nil]; swrevealviewcontroller *vc = [sb instantiateviewcontrollerwithidentifier:@"initialvc"]; [self presentviewcontroller:vc animated:yes completion:null]; } }
i error warning: attempt present <swrevealviewcontroller: 0x7ff20a595220> on <mposetuponeviewcontroller: 0x7ff20a720b80> view not in window hierarchy!
(i using swrevealviewcontroller
in app menu.)
i error, , view controller not switch. there way can switch storyboards based on nsuserdefault
? maybe in appdelegate?
just move code viewdidappear:
. in viewwillappear:
, view not in interface yet (that "will" means), there nothing present from.
Comments
Post a Comment