我有一个 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