Reputation: 2590
I have a button with a action (toggleApplication) that opens another application. When I return to my application from the one that was opened I want to segue to another view. But I get the following error from my code:
Receiver (RootViewController: 0x1f192450) has no segue with identifier 'showReceipt'
AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
RootViewController *controller = [RootViewController alloc];
return [controller handleURL:url];
}
RootViewController.m
- (IBAction)toggleApplication:(id)sender{
// Open application
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:theUrlString]];
}
- (BOOL)handleURL:(NSURL *)url{
[self performSegueWithIdentifier:@"showReceipt" sender:self];
return YES;
}
Upvotes: 2
Views: 1818
Reputation: 2590
Figured it out by using NSNotificationCenter.
AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
[[NSNotificationCenter defaultCenter] postNotificationName:@"segueListener" object:nil];
return YES;
}
RootViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiptSegue) name:@"segueListener" object:nil];
}
- (IBAction)toggleApplication:(id)sender{
// Open application
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:theUrlString]];
}
- (void)receiptSegue{
[self performSegueWithIdentifier:@"showReceipt" sender:self];
}
Does exactly what I want. Don't know if it's the right approach though.
Upvotes: 3