-1

I have a UIWebView that uses a ATM HUD while the web page is loading. I can get the HUD to start working, but after the web page loads, it stays there. I need to find a way to get the HUD to stop spinning once loaded. Below is the code I have so far..

@implementation ThenewsViewController

@synthesize hud;

- (void)showHud {
    // Show hud with activity indicator
    NSLog(@"hud: %@", hud);
    if (!hud) {
        hud = [[ATMHud alloc] initWithDelegate:self];
        [self.navigationController.view addSubview:hud.view];
        [hud setCaption:@"Loading news..."];
        [hud setActivity:YES];
        [hud update];

        if (![hud isBeingPresented])
            [hud show];
    } else {
        NSLog(@"hud exists... resetting.");
        hud = nil;
        [self showHud];
    }
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *myURL = [NSURL URLWithString:@"http://www.hiphopdx.com/m/index.php?s=news"];

    NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];

    [myWebView loadRequest:myRequest];

    UIColor *navBarColor = UIColorFromRGB(0x089932);
    [[self.navigationController navigationBar] setTintColor:navBarColor];

    if (![hud isBeingPresented])
        [self showHud];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

}

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

    NSLog(@"Done loading web view");
    [hud hide];
}

@end
Adam_GD
  • 11
  • 2

2 Answers2

0

How about this?

ATMHud *blargh;


if(loaded)
{
blargh.hidden = YES;
}
Exothug
  • 339
  • 4
  • 18
0

Try this:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
// stop animating here

}

also

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
// stop animating here also

}

Also make sure your "myWebView" instance delegate is set. F.e _myWebView.delegate = self;

Injectios
  • 2,777
  • 1
  • 30
  • 50