本文介绍了MBProgressHUD和UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在填充TableView时正在显示HUD,但似乎显示在TableView后面(tableview分隔符破坏了HUd).

I am displaying a HUD while populating the TableView, but it seems to be showing behind the TableView (tableview separator breaking the hud).

这是TableViewController中的代码:

Here's the code in the TableViewController:

- (void)viewDidLoad {
[super viewDidLoad];

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"Loading";

// Populate the table
[self getTableData];

self.tableView.rowHeight = 90;
}

它仅使用TableViews来完成.

It's doing this only with TableViews.

推荐答案

此处的问题是,视图加载时您正在添加HUD,这可能是在显示tableView之前,因此创建了tableView并显示为盖住HUD.将该代码移到viewDidAppear中,您的问题将消失:

The issue here is that you are adding the HUD when the view loads, which is likely before your tableView has been displayed, so the tableView is created and appears to cover the HUD. Move that code into viewDidAppear and your problem will go away:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = @"Loading";
}

这篇关于MBProgressHUD和UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:45