2013-03-27 7 views
2

다른 응용 프로그램을 여는 동작 (toggleApplication)이있는 단추가 있습니다. 내가 열린 응용 프로그램에서 응용 프로그램으로 돌아 왔을 때 나는 다른보기로 전환하려고합니다.AppDelegate의 openURL 이후 Segue

수신기 (RootViewController : 0x1f192450)하지만 난 내 코드에서 다음과 같은 오류가

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 

     RootViewController *controller = [RootViewController alloc]; 

     return [controller handleURL:url]; 

    } 

RootViewController.m 'showReceipt'

AppDelegate.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

- (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]; 
    } 

정확히 내가 원하는 것을

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 

     [[NSNotificationCenter defaultCenter] postNotificationName:@"segueListener" object:nil]; 

     return YES; 

    } 

RootViewController.m. 그래도 올바른 접근 방법인지는 모르겠다.