在进入下一个视图控制器之前,我想显示MBProcessHUD 5秒。这是当前的实现。
-(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];
}不幸的是,HUD根本不显示。
发布于 2014-07-04 08:59:47
尝试:
-(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];
}虽然这应该有效,但我假设您将执行一些处理来尝试登录用户?在这种情况下,您可以使用:
[hud showAnimated:YES whileExecutingBlock:^{
//Log the user in:
} completionBlock:^{
//Then push the new view here, the hud will automatically dismiss.
}];https://stackoverflow.com/questions/24570343
复制相似问题