-1

我有一个 UIWebView,它在网页加载时使用 ATM HUD。我可以让 HUD 开始工作,但在网页加载后,它仍然存在。我需要找到一种方法让 HUD 在加载后停止旋转。下面是我到目前为止的代码..

@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
4

2 回答 2

0

尝试这个:

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

}

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

}

还要确保您的“myWebView”实例委托已设置。Fe _myWebView.delegate = self;

于 2013-07-10T11:16:01.250 回答
0

这个怎么样?

ATMHud *blargh;


if(loaded)
{
blargh.hidden = YES;
}
于 2013-07-10T11:14:45.937 回答