使用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
可能是什么原因?