I wrote the following code, but when I run it, it says which view is not in the window hierarchy!
LoginViewController.m
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear: animated ];
[self presentViewController:
[self.storyboard]
instantiateViewControllerWithIdentifier:@"AgreementVC"]
animated —YES
completion:nil];
}
@ "AgreementVC" is the storyboard ID assigned to the AgreementViewController.
The LoginViewController appears first.
I tried it on hand, but I was able to transition without any problems.
Tried
·Add a UIViewController to the Main.storyboard
·Added CustomViewController class
·Associate CustomViewController with UIViewController added to Main.storyboard
class —CustomViewController
Storyboard ID:CustomVC
·Add the following code to ViewController (made when creating the project)
- (void) viewDidAppear: (BOOL) animated
{
[super viewDidAppear: animated ];
[self presentViewController:
[self.storyboard]
instantiateViewControllerWithIdentifier:@"CustomVC"]
animated —YES
completion:nil];
}
Also, I tried the pattern using Segue, and it worked fine.
[self performSegueWithIdentifier:@"toCustomVC" sender:self];
The error (which view is not in the window hierarchy!) occurs when you use viewDidLoad to perform screen transitions, so if you are doing something with viewDidLoad, why don't you comment out and try it?
© 2024 OneMinuteCode. All rights reserved.