문제

I am using a table view and trying to show MBProgressHud for cell selections that take a long time to present a modal (2.5 seconds).

Here is how I am starting MBProgressHud:

- (void)showProgressHud
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD showHUDAddedTo:self.streamTableView animated:YES];
    });
}

- (void)hideProgressHud
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.streamTableView animated:YES];
    });
}

I have noticed that the progress HUD shows only when the network activity indicator is not spinning.

The network becomes active when the table is being reloaded (using Restkit 0.20.0). I have AFNetworking configured to start the activity indicator when there is an open connection.

I have verified that if I disable the activity indicator the problem does not go away:

[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:NO];

I'd really like to be able to keep the option enabled either way. Any suggestions?

도움이 되었습니까?

해결책 2

It looks like the network activity indicator was tying up the run loop that MBProgressHud uses.

I ended up using this technique to allow the MBProgressHud time to show before the indicator ties up the loop again.

- (void)showProgressHud
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD showHUDAddedTo:self.streamTableView animated:YES];
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
    });
}

다른 팁

It would seem that you are running your network code on the main thread and that blocks any UI updates until it is complete. Check how you're starting the network connection following cell selection / reloading and ensure that it is being queued onto a background thread. The activity indicator is completely separate to your app code (indeed it runs on a different thread and that's why it works and is not affected by nor affecting you app UI).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top