Adnan Qadir
Adnan Qadir

Reputation: 35

how to hide progressview when webview load

hi I want to ask a simple question how I can hide or disable progress bar when UIWebView load, I add ProgressBar as subview of webview . I did it by using this way in the method below, but it can't help me because every site take different time to load because of their content size so kindly tell me how I can hide or remove the ProgressBar when any site load in webview

- (void)makeMyProgressBarMoving {  

    float actual = [threadProgressView progress];  

    if (actual < 1) {  
        threadProgressView.progress = actual + 0.2;  
        [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];  
    }  
    else
    {
        threadProgressView.hidden = YES;
        threadValueLabel.hidden = YES;
    }
} 

Upvotes: 1

Views: 2336

Answers (2)

Midhun MP
Midhun MP

Reputation: 107211

Check your webview is loaded completly or not.

if(!yourWebView.loading)
{
   [yourProgress removeFromSuperView];
}

loading

A Boolean value indicating whether the receiver is done loading content. (read-only) @property(nonatomic, readonly, getter=isLoading) BOOL loading >

Discussion

If YES, the receiver is still loading content; otherwise, NO. Availability

Available in iOS 2.0 and later.

or

You can implement the webViewDidFinishLoad delegate method of UIWebView.

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
   [yourProgress removeFromSuperView];
}

webViewDidFinishLoad:

Sent after a web view finishes loading a frame. - (void)webViewDidFinishLoad:(UIWebView *)webView

Parameters

webView

The web view has finished loading.

Availability

Available in iOS 2.0 and later.

Refer UIWebViewDelegate,UIWebView for more details

Upvotes: 0

P.J
P.J

Reputation: 6587

First add delegate to UIWebView For adding progress bar :- Web view delegate method :-

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    threadProgressView.hidden = NO;
}

For Removing progress bar :- Web view delegate method :-

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    threadProgressView.hidden = YES;
}

Hope this helps you

Upvotes: 2

Related Questions