MBProgressHUD意外消失

时间:2015-12-28 14:11:22

标签: ios mbprogresshud

使用MBProgressHUB时,我遇到了一个非常典型的问题。我的问题是,每当我[MBProgressHUD showHUDAddedTo:window animated:NO]呼叫[someTextField resignFirstResponder]时,MBProgressHUB就会显示1-2秒并立即消失。这是我的代码: - 的 AppDelegate.m

 + (MBProgressHUD *)showGlobalProgressHUD {
        UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
        [MBProgressHUD hideAllHUDsForView:window animated:YES];
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:NO];
        return hud;
    }

    + (void)dismissGlobalHUD {
        UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
        [MBProgressHUD hideHUDForView:window animated:NO];
    }

,在ViewController.h中

 @interface ViewController ()<UITextFieldDelegate>
    @property (weak, nonatomic) IBOutlet UITextField *textFiled1;

    @end

    @implementation ViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.textFiled1.delegate = self;
        // Do any additional setup after loading the view, typically from a nib.
    }


    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
        [textField resignFirstResponder];
        // shows MBProgressHUD for 1-2 secs and disappears by itself

        // I want to dismiss manually ?
        [AppDelegate showGlobalProgressHUD]; 
        return NO;
    }

@end

可能是什么原因?

0 个答案:

没有答案