0

我使用此代码显示 MBProgress

- (void)showSimple {
    // The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];


    // 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(myTask) onTarget:self withObject:nil animated:YES];}

- (void)myTask {
    // Do something usefull in here instead of sleeping ...
    sleep(3);
}

我希望在不运行 MyTask 但此方法时显示活动指示器

- (void)request:(FBRequest *)request didLoad:(id)result {
}

我试图改变

[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

[HUD showWhileExecuting:@selector(request) onTarget:self withObject:nil animated:YES];

或者

[HUD showWhileExecuting:@selector(didLoad) onTarget:self withObject:nil animated:YES];

但它不起作用

4

1 回答 1

0

我实际上更喜欢它SVProgressHUDMGProgressHUD因为它更好,但无论如何。回到你的问题。

你正在做的问题是你没有考虑到你的方法的参数。只要您的方法不需要参数,您就可以更改选择器以包含两个空参数:

[HUD showWhileExecuting:@selector(request::) onTarget:self withObject:nil animated:YES];
于 2011-11-24T21:07:08.420 回答