如何将MBProgressHUD的位置固定在UITableView的中心位置

Ris*_*nna 7 objective-c uitableview ios mbprogresshud uirefreshcontrol

我有一个场景,我在UITableViewController上使用第三方库MBProgressHUD,但问题是每当我上下滚动HUD移动滚动.

我不想禁用UITableView滚动,我也希望将HUD保持在UITableView的中心.

有可能实现它吗?

Bri*_*ian 6

将HUD添加到表视图的超级视图或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];
}
Run Code Online (Sandbox Code Playgroud)