I am using MBProgressHUD for showing loading while performing local long method to put user good experience. All working fine but now i have to implement like that if the method executes within a second than the loading should not be appear. I have gone through the MBProgressHUD samples and for this functionality i found the setGraceTime
and setMinShowTime
show time but its all not working properly. because when i put set grace time the loading icon is not appear even the method execution time is more than 1 second.Here is my code
if (self.HUD == nil)
{
self.HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:self.HUD];
}
self.HUD.labelText = @"Please wait.....";
// [self.HUD setMinShowTime:2.0f];
[self.HUD setGraceTime:1.0f];
[self.HUD setTaskInProgress:YES];
[self.HUD show:YES];
// [self.HUD hide:YES afterDelay:3];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
if (mycondition == nil)
{
[self myTask:[NSURL fileURLWithPath:strPath]];
//[self performSelector:@selector(mytask:) withObject:[NSURL fileURLWithPath:strPath]];
}
else
{
//else
}
self.tempView.hidden = YES;
// self.HUD.taskInProgress = NO;
[self.HUD hide:YES];
self.HUD = nil;
I have putted [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
for this problem's solution
please guide me what wrong in this code..?!