Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios MBProgressHUD和UITableView_Ios_Uitableview_Mbprogresshud_Hud - Fatal编程技术网

Ios MBProgressHUD和UITableView

Ios MBProgressHUD和UITableView,ios,uitableview,mbprogresshud,hud,Ios,Uitableview,Mbprogresshud,Hud,我在填充TableView时显示了一个HUD,但它似乎显示在TableView后面(TableView分隔符破坏了HUD) 以下是TableViewController中的代码: - (void)viewDidLoad { [super viewDidLoad]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.mode = MBProgressHUDModeText; hud.l

我在填充TableView时显示了一个HUD,但它似乎显示在TableView后面(TableView分隔符破坏了HUD)

以下是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;
}

它仅在tableView中执行此操作。

这里的问题是,在加载视图时添加HUD,这可能是在显示tableView之前,因此创建tableView并显示为覆盖HUD。将该代码移动到ViewDidDisplay中,您的问题就会消失:

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

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

如果要在
viewdiload
中实现,请使用
self.navigationController.view
而不是
self.view
,包括:

#import <QuartzCore/QuartzCore.h>
zPosition值越高,显示优先级越高

Even in ViewDidLoad also we can handle it like this::   
  - (void)viewDidLoad {
 [super viewDidLoad];     
   MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  hud.labelText = @"Loading..";
  dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
   [self contactsFromAddressBook];
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.view animated:YES];
       [self.tableView reloadData];

     });
  });

}

这应该是公认的答案!而
MBProgressHUD
的演示也使用了这个
Even in ViewDidLoad also we can handle it like this::   
  - (void)viewDidLoad {
 [super viewDidLoad];     
   MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  hud.labelText = @"Loading..";
  dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
   [self contactsFromAddressBook];
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.view animated:YES];
       [self.tableView reloadData];

     });
  });