0

iOS5 SDK と Phonegap 1.0.0 にアップグレード中のアプリがあります。

Childbrowser プラグインは正常に動作していますが、iTunes アプリ ストアへのリンクをクリックすると、リンクが Childbrowser ウィンドウで開かれます。

ChildBrowser プラグインを使用しない場合は、Appstore で直接開くことをお勧めします。

これはアプリストアのリンクです(アプリストア内のレビュー投稿ページへのリンクです)

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=386470812&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8

これが AppDelegate の変更方法です

AppDelegate.m を下にスクロールして、以下を置き換えます。

- (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
{
NSURL *url = [request URL];
if ([[url scheme] isEqualToString:@"gap"] || [url isFileURL]) {
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}
else {
ChildBrowserViewController* childBrowser =
[ [ ChildBrowserViewController alloc ] initWithScale:FALSE ];
[super.viewController presentModalViewController:childBrowser
animated:YES ];
[childBrowser loadURL:[url description]];
[childBrowser release];
return NO;
}
}

このブログ投稿で説明されている方法を使用して、Childbrowser を起動して実行しました http://iphonedevlog.wordpress.com/2011/09/24/installing-childbrowser-into-xcode-4-with-phonegap-1-0-mac -os-x-snow-leopard/

これを変更して目的のアクションを生成する方法について何か考えはありますか?

どうもありがとう..

4

1 に答える 1

2

メソッドと属性を使用して、URL に部分文字列としてhttp://itunes.apple.com/が含まれているかどうかを確認する必要があります。 次のように、URL と呼ばれる JavaScript を確認してください。rangeOfString:location

window.location="http://itunes.apple.com/us/app/code-check-basic-free-medical/id386470812?mt=8";
または任意の jquery メソッドを使用できます。メソッドを次のスニペットに
置き換えてください。shouldStartLoadWithRequest:

/**
 * Start Loading Request
 * This is where most of the magic happens... We take the request(s) and process the response.
 * From here we can re direct links and other protocalls to different internal methods.
 */
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:
(NSURLRequest *)request navigationType:
(UIWebViewNavigationType)navigationType
{
  NSURL *url = [request URL];
  if ([[url scheme] isEqualToString:@"gap"] || [url isFileURL]) {
    return [ super webView:theWebView shouldStartLoadWithRequest:request
            navigationType:navigationType ];
  }
  else {
    //here we will check whether urlString has http://itunes.apple.com/ as substring or not
    NSString* urlString=[url absoluteString];
    if ([urlString rangeOfString:@"http://itunes.apple.com/"].location == NSNotFound){
      ChildBrowserViewController* childBrowser = [ [ ChildBrowserViewController alloc ] initWithScale:FALSE ];
      childBrowser.modalPresentationStyle = UIModalPresentationFormSheet;
      childBrowser.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;   
      [super.viewController presentModalViewController:childBrowser animated:YES ];   
      [childBrowser loadURL:urlString];
      [childBrowser release];
      return NO;      
    }
    else 
      return YES;      
  }
}

ありがとう、
マユル

于 2011-11-04T05:31:17.333 に答える