2011-08-22 9 views
0

UIWebViewがまだページを読み込んでいる限り、カスタム読み込み用の.gifや別のイメージを表示する簡単な方法を探しています。ロード中にUIWebViewに読み込み用のGIFを設定する

は私が

– webViewDidStartLoad:(UIWebView *)webView 

でそれをしなければならない知っているが、どのように、私はイメージをロードしていますか?

+1

からそれを削除するには、UIActivityViewを使用することができますので、正確に何が、GIFのですか? –

答えて

2

これを試してみてください。

– webViewDidStartLoad:(UIWebView *)webView { 

     UIImageView *animatedImages; 
     NSMutableArray *imageArray; 

      // Array to hold jpg images 
     imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT]; 

      // Build array of images, cycling through image names 
     for (int i = 0; i < IMAGE_COUNT; i++) 
      [imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"yourGifImage%d.jpg", i]]]; 

      // Animated images - centered on screen 
     animatedImages = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,IMG_HEIGHT,IMG_WIDTH)]; 

      animatedImages.center = self.webView.center; 

     animatedImages.animationImages = [NSArray arrayWithArray:imageArray]; 

      // One cycle through all the images takes 1 seconds 
     animatedImages.animationDuration = 1.0; 

      // Repeat forever 
     animatedImages.animationRepeatCount = 0; 

     animatedImages.tag = 1; 

     [animatedImages startAnimating]; 

      // Add to webview 
     [self.webView addSubview:animatedImages]; 

    } 

webViewDidFinishLoad:方法でスーパー

- (void)webViewDidFinishLoad:(UIWebView *)webView { 

    UIView * removeAminatingImages = [self.webView viewWithTag:1]; 
    [removeAminatingImages removeFromSuperview]; 
} 
+0

これはアニメーション画像の面白い実装ですが、より適しているのはUIActivityViewです – Daniel

+0

なぜ画像が.lpgで終わるのか教えてください。そして、私はgngのすべてのフレームをpngとして取るのですか? – spankmaster79

+0

@spankmasterそれはちょうど間違いを入力していた私はそれを編集した – Gyani

関連する問題