2

別のアプリケーションを開くアクション(toggleApplication)のボタンがあります。開いたアプリケーションからアプリケーションに戻るときは、別のビューに移りたいと思います。しかし、コードから次のエラーが発生します。

レシーバー(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

- (IBAction)toggleApplication:(id)sender{

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

}

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

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

     return YES;

}
4

1 に答える 1

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

まさに私がやりたいことをします。しかし、それが正しいアプローチかどうかはわかりません。

于 2013-03-27T14:28:55.273 に答える