objective c - iOS whose view is not in the window hierarchy -


while moving passcode controller otp viewcontroller, iam getting following error in console:

warning: attempt present < otpcontroller: 0x1e56e0a0 > on < passcodecontroller: 0x1ec3e000> view not in window hierarchy!

this code i'm using change between views:

uistoryboard  *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil];     otpviewcontroller *lotpviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"otpviewcontroller"];     lotpviewcontroller.comingfromreg = true;      [self presentviewcontroller:lotpviewcontroller animated:yes                      completion:nil]; 

i presenting passcode controller registrationviewcontroller:

uistoryboard* storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil];         passcodeviewcontroller *passvc =  [storyboard instantiateviewcontrollerwithidentifier:@"passcodeviewcontroller"];         [self presentviewcontroller:passvc animated:yes completion:nil]; 

that happen because of 2 viewcontroller present , dismiss @ same time or trying present viewcontroller @ viewcontroller open viewdidload method

first:

  • present viewcontroller viewdidappear method or instead of viewdidload.

second:

i suggest make use of completion method present , dismiss viewcontrolelr following example:

[self presentviewcontroller:lotpviewcontroller animated:yes                              completion:^{          }]; 

update:

create separate method of presenting otpviewcontroller following:

-(void)presentotpviewcontroller {      uistoryboard  *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil];     otpviewcontroller *lotpviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"otpviewcontroller"];     lotpviewcontroller.comingfromreg = true;      [self presentviewcontroller:lotpviewcontroller animated:yes                      completion:^{}];  } 

now call method 1 second delaya using performselector

[self performselector:@selector(presentotpviewcontroller) withobject:self afterdelay:1.0 ]; 

you need put above performselect code in

[self dismissviewcontrolleranimated:yes completion:^{  [self performselector:@selector(presentotpviewcontroller) withobject:self afterdelay:1.0 ]; }]; // dismiss method of passcodeviewcontroller 

t


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -