2013-03-27 103 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]; 
    } 

不正是我想要的。不知道這是否是正確的方法。

相關問題