ここでは、MBProgressHUD の使用は簡単であると述べています。しかし、私はそれを作ることができません。
ここに私のコード:
- (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];
}
メソッドの実行中は進行状況インジケーターは表示されませんsavePage save
が、ページが完全に保存された後に表示されます (インジケーターが表示されるのは 1 秒未満です)。
私もこの方法を試しました:
- (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];
}
しかし、まだ運がありません。ここで私が欠けている場所を教えてくれる人はいますか?
PS:savePage save
すべての Web サイトのコンテンツをローカル ディレクトリに保存しています。保存が完了したら、progressHUD が消えたらいいのにと思います。
ありがとう