OGeek|极客世界-中国程序员成长平台

标题: IOS MBProgressHUD显示位置错误(不在中心,加载显示在左上角。) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 23:50
标题: IOS MBProgressHUD显示位置错误(不在中心,加载显示在左上角。)

我使用 MBProgressHUD showWhileExecuting 从网络查询一些数据,但 MBProgressHUD 有时不在中心

enter image description here

在图片上(红色数字):

loading 显示在左上角,backgound 显示在中间。

1.loading显示不在MBProgressHUD的背景上 2.只显示一个不包含加载的背景

-(void)viewDidLoad
{
    //other code ...

    mb = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    // --> i try which causes also an error
    //[[MBProgressHUD alloc] initWithWindow:self.view.window]; 
    // --> error too
    //[[MBProgressHUD alloc] initWithView:self.view];
    mb.labelText = @"loding city...";

    [self.navigationController.view addSubview:mb];
    [mb showWhileExecutingselector(queryCity 
                  onTarget:self 
                withObject:[NSNumber numberWithInt:1] 
             animated:YES];
}

-(void)queryCityNSNumber*)flag
{
    //query some data from network.
}



Best Answer-推荐答案


仅供引用:我通过说修复了它

[[[UIApplication sharedApplication] keyWindow] addSubview:_progress];

而不是

[self.view addSubview:_progress];

我不太喜欢它,也因为它在另一种情况下与 self.view 一起使用,但我在这里没有看到其他选项。

关于IOS MBProgressHUD显示位置错误(不在中心,加载显示在左上角。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13558039/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4