How to fix the position of MBProgressHUD to center in a UITableView

I have a scenario where I am using third party library MBProgressHUD on a UITableViewController but the issues is whenever I scroll up and down the HUD moves with the scroll.

I don't want to disable the UITableView scroll and also I want to keep the HUD in the centre of the UITableView.

Is there a possible way of implementing it?


将HUD添加到tableview的超级视图或navigationController.view修复问题:

UIView *view = self.tableView.superview;
// UIView *view = self.navigationController.view; if you are using navigationController
if (view != nil) {
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
}

这个问题可能是你在tablview中添加HUD,所以在你的视图中加入..

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

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

Create the object of MBProgressHUD(example: MBProgressHUD *HUD). Initialize it and add HUD as subview on your main view and do this

[HUD setCenter:self.view.center];
[HUD setUserInteractionEnabled:YES];
链接地址: http://www.djcxy.com/p/83886.html

上一篇: jquery如何比较字符串到其他字符串的结尾

下一篇: 如何修复MBProgressHUD在UITableView中的位置