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 5942301
In Process

The Archive Base Latest Questions

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

My myViewController.h contains: #import <UIKit/UIKit.h> @interface myViewController : UIViewController { UIScrollView *myScrollView; UIView *mySubView;

  • 0

My myViewController.h contains:

#import <UIKit/UIKit.h>

@interface myViewController : UIViewController {

    UIScrollView *myScrollView;

    UIView *mySubView;

    UIWebView *myWebView;

    UIActivityIndicatorView *myIndicator;

}

@property (nonatomic, retain) IBOutlet UIScrollView *myScrollView;

@end

My myViewController.m contains:

#import "myViewController.h"

@implementation myViewController

@synthesize myScrollView;

...

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSArray *bgColors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];

    for (int i = 0; i < bgColors.count; i++)
    {
        CGRect frameNew;
        frameNew.origin.x = self.myScrollView.frame.size.width * i;
        frameNew.origin.y = 0;
        frameNew.size = self.myScrollView.frame.size;

        mySubView = [[UIView alloc] initWithFrame:frameNew];
        mySubView.backgroundColor = [bgColors objectAtIndex:i];

        [self.myScrollView addSubview:mySubView];

        myIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        myIndicator.center = CGPointMake(160, 100);
        myIndicator.hidesWhenStopped = NO;

        CGRect webFrame = CGRectMake(self.myScrollView.frame.size.width * i, 0, 320, 320);
        myWebView = [[UIWebView alloc] initWithFrame:webFrame];
        [myWebView setDelegate:(id)self];
        [myWebView addSubview:myIndicator];

        NSString *urlAddress = @"http://www.google.com/";
        NSURL *url = [NSURL URLWithString:urlAddress];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [myWebView loadRequest:requestObj];

        [self.myScrollView addSubview:myWebView];

        [myIndicator release];
        [myWebView release];
        [mySubView release];
    }

    self.myScrollView.contentSize = CGSizeMake(self.myScrollView.frame.size.width * bgColors.count, self.myScrollView.frame.size.height);
}

-(void)webViewDidStartLoad: (UIWebView *)webView
{
    NSLog(@"Web view did start loading");
    [myIndicator startAnimating];
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

-(void)webViewDidFinishLoad: (UIWebView *)webView
{
    NSLog(@"Web view did finish loading");
    [myIndicator stopAnimating];
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [myIndicator stopAnimating];
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    NSString* errorString = [NSString stringWithFormat:@"<html>%@</html>", error.localizedDescription];
    [myWebView loadHTMLString:errorString baseURL:nil];
}

...

Load indicator does not work on the first two mySubView in myWebView, works only on the last mySubView in myWebView.

In the first two mySubView in myWebView, myIndicator displayed but not active.

Tell me what’s wrong doing?

  • 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-22T16:14:03+00:00Added an answer on May 22, 2026 at 4:14 pm

    That is because myIndicator is pointing to the last activity indicator view. All previous references are lost. Luckily, since it is a subview of the web view, we can get a reference to it. This should help –

    -(void)webViewDidStartLoad: (UIWebView *)webView
    {
        UIActivityIndicatorView *actView;
        for ( id object in webView.subviews ) {
            if ([object isMemberOfClass:[UIActivityIndicatorView class]]) {
                actView = (UIActivityIndicatorView*)object;
            }
        }
        NSLog(@"Web view did start loading");
        [actView startAnimating];
        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
    }
    
    -(void)webViewDidFinishLoad: (UIWebView *)webView
    {
        UIActivityIndicatorView *actView;
        for ( id object in webView.subviews ) {
            if ([object isMemberOfClass:[UIActivityIndicatorView class]]) {
                actView = (UIActivityIndicatorView*)object;
            }
        }
        NSLog(@"Web view did finish loading");
        [actView stopAnimating];
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    }
    
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
    {
        UIActivityIndicatorView *actView;
        for ( id object in webView.subviews ) {
            if ([object isMemberOfClass:[UIActivityIndicatorView class]]) {
                actView = (UIActivityIndicatorView*)object;
            }
        }
        [actView stopAnimating];
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        NSString* errorString = [NSString stringWithFormat:@"<html>%@</html>", error.localizedDescription];
        [myWebView loadHTMLString:errorString baseURL:nil];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ViewController that looks like this: @interface MyViewController : UIViewController<UIScrollViewDelegate> {
In objective-c, I can do something like @interface MyViewController : UIViewController <UITextInputDelegate> to create
I have a zooming UIScrollView that contains a UIView which contains some custom UIViews
Inside Interface Builder I have a UINavigationController, which contains a UIViewController, which has a
Under the documentation for UIViewController -> nibName property it says: This property contains the
So say in my viewcontroller's .h file I have: @interface MyViewController : UIViewController {
Let's say I have a simple view controller with one UITableView property: @interface MyViewController
in my code: #import MyViewController.h #import AVFoundation/AVAudioPlayer.h - (IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath =
I have a .h file containing... myViewController : UIViewController {} in the .m file
I'm asking my ViewController for it's view.center property and drawing a new UIView that

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.