ボタンを押すとストーリーボードのビューが変わるように機能するこのコードがあります。
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
ないので、これを修正する方法がわかりません。
誰でも助けることができますか?