开发者

UIActivityIndicator not shown on top of webview

开发者 https://www.devze.com 2023-02-14 10:15 出处:网络
I have a acitivity indicator and a webview. When I place the indicator on top of the webview, the acitivity indicator is not shown.

I have a acitivity indicator and a webview. When I place the indicator on top of the webview, the acitivity indicator is not shown.

I have tried the option of placing webview and activity indicator separately. When I do the same, the indicator is shown but when I place it on top of the webview the indicator is not shown.

I have tried the option of setting the background to be black for the indictor and for the webview i have kept the same to be white.

Can anyone pls help me on the same.

Below is the code

@synthesize webView, acitivityIndicator;


- (void)viewDidLoad {

    [super viewDidLoad];

    // Create a URL object
    NSURL *url = [NSURL URLWithString:urlAddress];


    NSLog(@"URL address is: %@", urlAddress);

    //URL Request Object

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    //Load the request in the UIWebView

    webView.delegate = self ;

    [[self view] addSubview:[self webView]];

    [[self webView] loadRequest:requestObj];
}

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

    NSLog(@"Web view did start loading");

    ac开发者_如何学运维itivityIndicator.hidden = NO;

    [acitivityIndicator startAnimating];    
}

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

    NSLog(@"Web view did finish loading") ;

    [acitivityIndicator stopAnimating];
}


The UIWebView itself may have a white background, so that's why you don't see the UIActivityIndicator.

You should make sure that:

  1. Your UIActivityIndicatorView is set to gray.
  2. Your UIActivityIndicatorView is "below" the UIWebView on Interface Builder. The items at the bottom really are at the top.

This is an example:

UIActivityIndicator not shown on top of webview

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号