Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:22:41+00:00 2026-05-31T16:22:41+00:00

I am trying to create an iPhone app as in the fig below: In

  • 0

I am trying to create an iPhone app as in the fig below:

enter image description here

In this i am dynamically adding some imageviews dynamically into a uiscroll view. Each imageview contains a UIButton and UIProgressView. When click on each it should different urls and the loading of each url should appear on the corresponding UIProgressView. I am using asynchronous method and it should load multiple progress views at the same time.
Here is the code i have used,

- (void)startDownload:(id)sender {

    UIButton *btn = (UIButton *)sender;
    int btnTag = btn.tag;
    selectedTag = btn.tag;

    for (int x=0; x < [urlArray count]; x++) {
        if (btnTag == x) {
            NSURL *url = [NSURL URLWithString:[urlArray objectAtIndex:x]];
            NSURLRequest *request = [NSURLRequest requestWithURL:url];

            NSURLConnection *theConnection = [[NSURLConnection alloc]initWithRequest:request delegate:self];

            [NSURLConnection sendAsynchronousRequest:request
                                               queue:[NSOperationQueue mainQueue]
                                   completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
                                       NSLog(@"Expected length: %lld ",response.expectedContentLength);
                                   }];
            if (theConnection) {
                receivedData = [NSMutableData data];                    
            }else {
                NSLog(@"Connection failed");
            }            
        }
    }
}

- (void)makeMyProgressMove{

    UIImageView *image = (UIImageView *)[mainView viewWithTag:selectedTag];
    UIProgressView *currentProgress = (UIProgressView *)[image viewWithTag:selectedTag];
    NSLog(@"Prog tag: %d",currentProgress.tag);

    if(currentProgress)
    {
        float actualProgress =  (_receivedDataBytes / (float)_totalFileSize);
        currentProgress.progress =  actualProgress;

    } else {
        NSLog( @"couldn't get the progress view for the image with tag: %d", selectedTag );
    }
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 
    _totalFileSize = response.expectedContentLength;
    receivedData = [[NSMutableData alloc] init];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    _receivedDataBytes += [data length];

    NSLog(@"Receiving data: %2f", _receivedDataBytes / (float)_totalFileSize);

    if ((_receivedDataBytes / (float)_totalFileSize) < 1) {
        [self performSelectorOnMainThread: @selector(makeMyProgressMove) withObject: NULL waitUntilDone:NO];
    }
    else if ((_receivedDataBytes / (float)_totalFileSize) == 1){
        [self performSelectorOnMainThread: @selector(makeMyProgressMove) withObject: NULL waitUntilDone:NO];
        _receivedDataBytes = 0;
        _totalFileSize = 0;
    }
    [receivedData appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
}

But its not working.
Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:22:42+00:00Added an answer on May 31, 2026 at 4:22 pm

    allocate each UIWebView with different url and and addSubView UIActivityIndicatorView to every UIWebView.Give tag for each UIActivityIndicator ..

    -(void)action  {
    
    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];
    
    //URL Request Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    UIWebView *webView = [[UIWebView alloc]initWithFrame:frame];//give y value incremented frame.
    
    UIActivityIndicatorView  *av = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    av.frame=CGRectMake(145, 160, 25, 25);
    av.center = webView.center;
    av.tag  = INDICATOR_TAG;
    [webView addSubview:av];
    webView.delegate = self;
    [av startAnimating];
    
    //Load the request in the UIWebView.
    [webView loadRequest:requestObj];
    }
    
    - (void)webViewDidFinishLoad:(UIWebView *)webView {
    
     UIActivityIndicatorView *indicator = [webView viewWithTag:INDICATOR_TAG];
    indicator.hidden = YES;
    
    }
    

    call this action{} method for showing multiple times.

    EDIT

    UIWebView doesn’t give you any progress information in the normal mode. What you need to do is first fetch your data asynchronously using an NSURLConnection. When the NSURLConnection delegate method connection:didReceiveResponse, you’re going to take the number you get from expectedContentLength and use that as your max value. Then, inside the delegate method connection:didReceiveData, you’re going to use the length property of the NSData instance to tell you how far along you are, so your progress fraction will be length / maxLength , normalized to between 0 and 1.

    Finally, you’re going to init the webview with data instead of a URL (in your connection:didFinishLoading delegate method).

    Reference :
    How to use UIProgressView while loading of a UIWebView?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this version of an iPhone app, I'm trying to create a new core
I am trying to create multiple views in my view-based iPhone app in Xcode
I'm trying to create a similar login/register view as the Tumblr's iPhone app. I
So I'm trying to create an iphone app that does simple temperature conversion and
In an iPhone app for iOS5 I'm trying to create a controller object that
I'm trying to create a normal rounded rectangular button in a new iPhone app
I am trying to create an iPhone app for a large website (as big
I'm trying to create an iphone app which grabs a JSON string, parses it
I'm trying to create a universal iPhone app, but it uses a class defined
to all im newbie developer and trying to create my first iPhone app, sorry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.