Android プログレス表示

Android プログレス表示(サークルで回るやつ)、同様のプログレスを iPhone で表示する方法、
両者を比べても言語が違うのだから意味もないことだが、忘れないために書きとめておく。

Android の場合、、、

layout の xml

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>

<FrameLayout
    android:id="@+id/progressBarWrapper"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:visibility="gone"
    android:paddingLeft="1dip"
    android:paddingRight="1dip">

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ProgressBar>

</FrameLayout>

WebViewClient の onPageStarted と onPageFinished をオーバーライドして
プログレスバーを表示・非表示を制御する

final View progressBarWrap = findViewById(R.id.progressBarWrapper);
WebView web = (WebView)findViewById(R.id.webview);
web.getSettings().setJavaScriptEnabled(true);
web.setWebViewClient(new WebViewClient(){
   @Override
   public void onPageStarted(WebView view,String url,Bitmap favicon){
      super.onPageStarted(view,url,favicon);
      progressBarWrap.setVisibility(View.VISIBLE);
   }
   @Override
   public void onPageFinished(WebView view,String url){
      super.onPageFinished(view,url);
      progressBarWrap.setVisibility(View.INVISIBLE);
   }
});

iPhone の場合、、、、

CGRectMake で、プログレス表示の座標と大きさを指定しなければならない。
  CGRectMake( X , Y , Width , Height )

@synthesize webView;
UIActivityIndicatorView  *indicator;

- (void)viewDidLoad {
    [super viewDidLoad];
    webView.delegate = self;

    indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    int screenW = [[UIScreen mainScreen] applicationFrame].size.width;
    int screenH = [[UIScreen mainScreen] applicationFrame].size.height;
    indicator.frame = 
CGRectMake((screenW/2)-25,(screenH/2)-25, 50.0, 50.0);
    indicator.contentMode = UIViewContentModeCenter;
    [self.view addSubview:indicator];
    // 別途、DOMAIN と PATH 文字列は #define で定義済みとして、
    NSString *url = [NSString stringWithFormat:@"http://%@/%@/index.html",DOMAIN,PATH];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
    [indicator startAnimating];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [indicator stopAnimating];
}