1

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;
    }
} 
Girish
  • 4,692
  • 4
  • 35
  • 55
Adnan Qadir
  • 35
  • 1
  • 6

2 Answers2

2

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

P.J
  • 6,547
  • 9
  • 44
  • 74
  • i added the progress bar as subview of webivew – Adnan Qadir Dec 26 '12 at 10:05
  • then you can use addSubView on hidden=NO and removeFromSuperView on hidden=YES; – P.J Dec 26 '12 at 10:07
  • dude one another question i wanted to ask you i am working on a project i am creating a photo gallary same as like in iphone photo gallary in which i added customs buttons on scroll view and i set the pictures as background on these buttons and when someone click on any of these pictures it will show the larger images on next view controller. i mean to say is it the right way that i am adding images in scrollview using buttons – Adnan Qadir Dec 26 '12 at 11:40
  • there are many third party libraries available, which will make your work easier. Visit http://www.cocoacontrols.com/, here just search and you will find any libraries free. Also, you can go with way you told, but remember to reduce size of image before placing to your button. – P.J Dec 26 '12 at 11:43
0

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

Midhun MP
  • 103,496
  • 31
  • 153
  • 200