1

最新バージョンのphonegapを使用してiOS内で外部リンクを開くにはどうすればよいですか?

4

1 に答える 1

1

解決策を見つけました

MainViewController.mでこのブロックのコメントを解除します

/* Comment out the block below to over-ride */
/*

- (void) webViewDidStartLoad:(UIWebView*)theWebView 
{
    return [super webViewDidStartLoad:theWebView];
}

- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error 
{
    return [super webView:theWebView didFailLoadWithError:error];
}

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
*/

この完全な機能を置き換えます

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

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
     NSURL *url = [request URL];
     if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) 
     {
        return YES;
     }
     else {
        return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
     }
 }
于 2012-04-13T03:54:33.880 に答える