今天遇見一個奇怪的bug,當我的UIAlertView 消失的時候鍵盤彈出來了,這個只出現(xiàn)在第一次安裝的時候
萬能的stackoverflow上面有這個問題的一些解決方案:
- 使用新的api,UIAlertController
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert Title!" message:@"This is an alert message." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alertController addAction:ok];
[self presentViewController:alertController animated:NO completion:nil];
2.另外一個方法就是延遲調(diào)用一下alertView
@weakify(self);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@strongify(self);
[self loadUpdateAPI];
});
3.另外一種注銷鍵盤
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
** 出現(xiàn)的原因**
可能是鍵盤狀態(tài)沒有完全被收回,導致出現(xiàn)的
如果有更好的方案可以告訴我