Reputation: 287
Before I move to my next view controller I'd like to display MBProcessHUD for 5 seconds. This is the current implementation
-(void)login
{
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view];
[hud setDimBackground:YES];
[hud setOpacity:0.5f];
[hud show:YES];
[hud hide:YES afterDelay:10.0];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *obj=[storyboard instantiateViewControllerWithIdentifier:@"accountTableViewController"];
[self.navigationController pushViewController:obj animated:YES];
}
Unfortunately the HUD does not display at all.
Upvotes: 1
Views: 2510
Reputation: 5681
Try:
-(void)login
{
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view];
[hud setDimBackground:YES];
[hud setOpacity:0.5f];
[hud show:YES];
[hud hide:YES afterDelay:5.0];
[self performSelector:@selector(pushView) withObject:nil afterDelay:5.0];
}
- (void) pushView {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITabBarController *obj=[storyboard instantiateViewControllerWithIdentifier:@"accountTableViewController"];
[self.navigationController pushViewController:obj animated:YES];
}
Although this should work, I assume you will be doing some processing to try and log a user in ? In which case you can use:
[hud showAnimated:YES whileExecutingBlock:^{
//Log the user in:
} completionBlock:^{
//Then push the new view here, the hud will automatically dismiss.
}];
Upvotes: 4