我能夠在viewDidLoad中成功顯示HUD指示符,但在webview完全加載時無法將其隱藏在webViewDidFinishLoad方法中。請幫忙。MBProgressHUD指示器不會隱藏
我使用下面的代碼::
在.h文件中
MBProgressHUD *HUD;
在viewDidLoad中
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *query = [[NSString alloc] initWithFormat:@"http://localhost/index.php?uid=%@", [[UIDevice currentDevice] uniqueIdentifier]];
NSURL *url = [[NSURL alloc] initWithString:query];
NSString *response = [[NSString alloc] initWithContentsOfURL:url];
if(response)
{
[webView loadRequest:[NSURLRequest requestWithURL:url]];
}
else
{
//NSLog(@"err %@",response);
}
HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain];
HUD.delegate = self;
HUD.labelText = @"loading";
}
和webViewDidFinishLoad
- (void)webViewDidFinishLoad:(UIWebView *)web
{
[HUD hide:TRUE]; //it does not work for me :(
}
如果找不到修復程序,請給[SVProgressHUD](https://github.com/samvermette/SVProgressHUD)一個試試。在你的情況,這將是簡單的調用'[SVProgressHUD showWithStatus:@「加載」]'然後'[SVProgressHUD解僱]' – samvermette
謝謝,SVProgressHUD正是我想要的,但它奇怪的是,它只適用於Xcode模擬器和不在我的iPad上,我做錯了什麼? –
嘗試在'viewDidAppear:'而不是'viewDidLoad'中顯示它。 – samvermette