首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MBProgressHUD不显示

MBProgressHUD不显示
EN

Stack Overflow用户
提问于 2014-07-04 08:54:23
回答 1查看 2.5K关注 0票数 1

在进入下一个视图控制器之前,我想显示MBProcessHUD 5秒。这是当前的实现。

代码语言:javascript
复制
-(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根本不显示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-04 08:59:47

尝试:

代码语言:javascript
复制
-(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];

}

虽然这应该有效,但我假设您将执行一些处理来尝试登录用户?在这种情况下,您可以使用:

代码语言:javascript
复制
    [hud showAnimated:YES whileExecutingBlock:^{
       //Log the user in:
    } completionBlock:^{
      //Then push the new view here, the hud will automatically dismiss. 
    }];
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24570343

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档