While i am Moving From PassCode Controller to OTP ViewController, iam getting the following error in console:
警告:尝试在<PassCodeController:0x1ec3e000>上显示<OTPController:0x1e56e0a0>,其视图不在窗口层次结构中!
This is the code I'm using to 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 am presenting PassCode Controller From RegistrationViewController:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PassCodeViewController *passVC = [storyboard instantiateViewControllerWithIdentifier:@"PassCodeViewController"];
[self presentViewController:passVC animated:YES completion:nil];
3 回答
这是因为两个viewcontroller同时存在和解除,或者你试图在viewcontroller打开
ViewDidload
方法时立即呈现ViewController所以First:
viewDidAppear
方法的ViewController或代替ViewDidload
.Second:
我建议使用完成方法当前和解除viewcontrolelr如下例:
UPDATE:
创建一个单独的方法来呈现OTPViewController,如下所示:
现在使用
performSelector
用1秒Delaya调用此方法您需要在上面执行selectselect代码
Ť
尝试从rootViewController呈现它,
[self.view.window.rootViewController presentViewController:lOTPViewController animated:YES completion:nil];
使用下面的代码行..