1

I have a MBProgressHUD that shows when data is being pulled on the background asynchronously. Sometimes when the network is slow this will take forever. So as of now I am just hiding it after 30 seconds if it hasn't been dismissed. What is a good way to dismiss this HUD for a slow network connection?

xonegirlz
  • 8,889
  • 19
  • 69
  • 127
  • Are you asking how to dismiss the HUD, or how to dismiss it after 30 seconds, or for an alternative solution to dismissing it after 30 seconds? – UIAdam Jan 31 '12 at 19:18
  • an alternative solution to dismissing it after 30 seconds. Cause what happens is that I can dismiss the HUD after 30 seconds, however something is still loading in the background and it's not yet finished. – xonegirlz Jan 31 '12 at 19:30

2 Answers2

4

I would say that the best solution is probably to keep the HUD up the whole time the data is loading so that the user knows that something is happening, and perhaps give them an option to cancel it if that is appropriate for your app. Alternatively, if it is possible for you to load and display the data piecemeal (i.e. before you have the entire set of data), then you should just display the HUD until you have enough data that you can start displaying something in the UI that the user can interact with.

Basically, what you want to avoid is a situation where it could appear to the user that nothing is happening and the UI is essentially blank with nothing for them to do.

UIAdam
  • 5,303
  • 1
  • 27
  • 23
  • I agree, you should probably stick to showing the HUD as long as you are pulling data. Using -showWhileExecuting has worked extremely well for me in this regard. If you stop showing it, the user will think it is done and try to interact, and that isn't good if there is no data. – Bill Burgess Jan 31 '12 at 20:18
  • yea, that's actually the issue... however how can I give the option to cancel while the HUD is spinning? Is there any such option? – xonegirlz Feb 01 '12 at 06:08
  • It doesn't depend on the HUD so much as how you are loading the data. You need some way of canceling your background data loading operation. – UIAdam Feb 01 '12 at 07:35
0

Implement MBProgressHUD delegate

it will be called every time whether if it is fast or slow network connection,In case of slow network connection there will be a time out and this delegate will be fired,remove the hud from the superview in this delegate

-(void)hudWasHidden
{
    [HUD removeFromSuperview];

}
Piyush Kashyap
  • 1,965
  • 1
  • 14
  • 16