Reputation: 738
In my app I need to after the application has been minimized, and then open the application screen switched to a certain ViewController, it introduces the password if it is correct, the view switches to the main screen.
My AppDelegate.m:
-(void)applicationDidEnterBackground:(UIApplication *)application {
EnterBackground *vc = [[EnterBackground alloc] init];
self.window.rootViewController = vc;
}
In the Storyboard, it looks like this:
And EnterBackground.m:
if ([checkCode isEqualToString:@"111"])
[self perfomSegueWithIdentifier:@"ss" sender: self];
But when I enter the password, and must go, an error that no segue with identifier 'ss'. Although it exists. I have a similar connection ( in green circle) with another ViewController, and modal segue works.
I tried also: [self navigationController performSegueWithIdentifier:@"ss" sender:self];
With this I don't see an error, but I can see only black screen.
What could be wrong?
Upvotes: 0
Views: 218
Reputation: 2629
You should get your 'EnterBackground' instance from the storyboard, not by initializing it manually. The info about segues of 'EnterBackground' comes from storyboard not from the class implementation. This is how you can initialize it properly:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryboardFilename" bundle:nil];
EnterBackground *vcEnterBackground = [storyboard instantiateViewControllerWithIdentifier:@"StoryboardIdentifierOfEnterBackground"];
Upvotes: 1
Reputation: 1584
In the applicationDidEnterBackground method try something like:
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
EnterBackground *vc = [storyboard instantiateViewControllerWithIdentifier:@"EnterBackgroundVC"];
self.window.rootViewController = vc;
Upvotes: 1