6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIWebViewではURLSchemeでのアプリ起動ができない?

Posted at

意外な動きだったので。URLSchemeを仕込んだ下記のようなページを用意した時に、Safariからゲームセンターを起動する事はできたが、UIWebViewからはできなかった。

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
	<a href="gamecenter:">ゲームセンター</a>
</body>
</html>

仕方ないので下記のようにしてみた。

- (BOOL)webView:(UIWebView *)aWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    //こうしないと起動できなかった。Safariでリンクを押した時は起動できるけどね。
    if([[[request URL] scheme] isEqual:@"gamecenter"]){
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    }

  }
  return YES;
}
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?