cant show MBProgressHUD
- by dejoong
In here said that using MBProgressHUD is easy.
But i cant make it.
Here my code:
- (IBAction)save{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
[HUD show:YES];
NSString *title = [page stringByEvaluatingJavaScriptFromString:@"document.title"];
SavePageAs *savePage = [[SavePageAs alloc] initWithUrl:self.site directory:title];
[savePage save];
[HUD hide:YES];
}
the progress indicator not show during [savePage save] method run, but show after the page completely saved (the indicator show for less than 1 second).
I also tried this way:
- (IBAction)save {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Saving...";
[HUD showWhileExecuting:@selector(performFetchOnMainThread) onTarget:self withObject:nil animated:YES];
}
- (void) savingPage{
NSString *title = [page stringByEvaluatingJavaScriptFromString:@"document.title"];
SavePageAs *savePage = [[SavePageAs alloc] initWithUrl:self.site directory:title];
[savePage save];
}
-(void) performFetchOnMainThread {
[self performSelectorOnMainThread:@selector(savingPage) withObject:nil waitUntilDone:YES];
}
but still no luck. Anyone let me know where im lack here??
P.S [savePage save] is saving all website contents to local directory. I wish once the saving is complete the progressHUD disappear.
Thanks