我有这段代码可以工作,所以一旦我按下按钮,我的故事板中的视图就会发生变化:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewController *viewController = (ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"view1"];
[self presentViewController:viewController animated:YES completion:nil];
此代码有效,但是当我再次使用它来更改回我的原始视图时,使用:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewController *viewController = (ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"view2"];
[self presentViewController:viewController animated:YES completion:nil];
它不起作用,我收到此错误:
Warning: Attempt to present <UIViewController: 0x863ad30> on <UITabBarController: 0x86309b0> whose view is not in the window hierarchy!
标识已设置,我不是我的功能,viewdidload
所以我不知道如何解决这个问题。
有人可以帮忙吗?