2013-03-27 61 views
2

我有一个按钮,其中包含一个可以打开另一个应用程序的操作(toggleApplication)。当我从打开的应用程序返回到我的应用程序时,我想继续看另一个视图。但我得到以下错误从我的代码:在AppDelegate中openURL之后继续之后

接收机(RootViewController的:0x1f192450)具有标识符 '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没有SEGUE

- (IBAction)toggleApplication:(id)sender{ 

    // Open application 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:theUrlString]]; 

} 

- (BOOL)handleURL:(NSURL *)url{ 

    [self performSegueWithIdentifier:@"showReceipt" sender:self]; 

    return YES; 

} 

回答

3

通过使用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]; 
    } 

不正是我想要的。不知道这是否是正确的方法。

相关问题