cant show MBProgressHUD

Posted by dejoong on Stack Overflow See other posts from Stack Overflow or by dejoong
Published on 2012-04-01T17:26:02Z Indexed on 2012/04/01 17:29 UTC
Read the original article Hit count: 516

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c