iOS8键盘扩展转到另一个App

时间:2014-11-14 03:19:12

标签: ios8 custom-keyboard

当我想在App1中打开App2时,我可以这样做:

NSURL * myURL_APP_A = [NSURL URLWithString:@"openurl1://"];

if ([[UIApplication sharedApplication] canOpenURL:myURL_APP_A]) {

[[UIApplication sharedApplication] openURL:myURL_APP_A];

}

但是当我想在键盘扩展中打开一个应用程序时,无法使用[UIApplication sharedApplication]。那么我该如何制作呢?

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

[UIApplication sharedApplication] openURL目前不允许在自定义键盘中使用。您应该会看到弹出的错误消息,告诉您确切的信息。

答案 1 :(得分:0)

您可以尝试以下方法:

NSURL *url = [NSURL URLWithString:@"myapp://"]; 
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
[self.view addSubview:webView];
[webView loadRequest:urlRequest];