我有一个uitableview从互联网加载数据,在此期间我显示MBProgressHUD.但问题是用户在加载表之前无法触摸包括上一页按钮在内的任何内容.这是我的代码两个不同的类:
//PROBLEM METHOD 1 - (void)viewDidLoad { [super viewDidLoad]; [tableEtkinlikler reloadData]; MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; HUD.labelText = @"Açılıyor..."; HUD.userInteractionEnabled = NO; [self performSelector:@selector(loadEtkinliklerTitlesAndImages) withObject:nil afterDelay:0]; tableEtkinlikler.dataSource = self; tableEtkinlikler.delegate = self; }
我也有一个按钮同样的问题..在它加载来自互联网的数据..
//PROBLEM METHOD 2 - (IBAction)AktivitelerButtonClicked:(UIButton *)sender { MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; HUD.labelText = @"Açılıyor..."; HUD.userInteractionEnabled = NO; [self performSelector:@selector(openAktivitelerWindow) withObject:nil afterDelay:0]; }
解决方法
我相信MBProgressHUD的重点,它为您提供了在完成任务时显示HUD的机会,一旦您的任务完成,您将其解除,以便用户可以与已完成的数据进行交互.
但是在某些情况下,加载数据需要很长时间,因此您可能希望让用户决定继续,选择其他选项或只是返回
在你的代码中这个HUD.userInteractionEnabled = NO;应该工作,但问题可能是showHUDAddedTo:self.view你不使用视图层次结构中可能的最高视图.
试着用这个:
- (IBAction)showSimple:(id)sender { // The hud will dispable all input on the view (use the higest view possible in the view hierarchy) HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; HUD.userInteractionEnabled = NO; // Regiser for HUD callbacks so we can remove it from the window at the right time HUD.delegate = self; // Show the HUD while the provided method executes in a new thread [HUD showWhileExecuting:@selector(loadEtkinliklerTitlesAndImages) onTarget:self withObject:nil animated:YES]; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。