【发布时间】:2016-09-03 18:31:18
【问题描述】:
当我从 PassCode 控制器移动到 OTP ViewController 时,我在控制台中收到以下错误:
警告:尝试在 on 其视图不在窗口层次结构中!
这是我用来在视图之间切换的代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
OTPViewController *lOTPViewController = [storyboard instantiateViewControllerWithIdentifier:@"OTPViewController"];
lOTPViewController.comingFromReg = true;
[self presentViewController:lOTPViewController animated:YES
completion:nil];
我正在从 RegistrationViewController 展示密码控制器:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PassCodeViewController *passVC = [storyboard instantiateViewControllerWithIdentifier:@"PassCodeViewController"];
[self presentViewController:passVC animated:YES completion:nil];
【问题讨论】:
-
从您呈现的位置 PassCodeController
-
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];改用 self.storyboard
-
AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; appDelegate.window.rootViewcontroller 存在...
-
@PKT 这与情节提要无关,请大家避免
-
谢谢大家。这段代码对我有用: OTPViewController *lOTPViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"OTPViewController"]; lOTPViewController.comingFromReg = true; [self.navigationController pushViewController:lOTPViewController 动画:YES];
标签: ios objective-c uiview uinavigationcontroller presentviewcontroller