6

私はインターネットからデータをロードするuitableviewを持っており、この期間中にMBProgressHUDを表示しています。ただし、問題は、テーブルが読み込まれる前に、ユーザーが前のページのボタンを含む何にも触れられないことです。これが2つの異なるクラスの私のコードです:

//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]; 
}
4

1 に答える 1

10

それがポイントであると私は信じてい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];
}
于 2013-01-30T14:00:17.503 に答える