UITextfield resignFirstResponder键盘不回收
2015-04-28 15:58
741 查看
#import <UIKit/UIKit.h> typedef void(^resignFirstResponderBlock)(BOOL hided); @interface UITextField (hideKeyBoard) //延时注销第一响应者 -(BOOL)resignFirstResponder:(resignFirstResponderBlock)block; @end
/**************************************************************************/
#import "UITextField+hideKeyBoard.h" @implementation UITextField (hideKeyBoard) /** * 延时注销第一响应者 * * @param block 延时后执行的事件 * * @return 判断 */ -(BOOL)resignFirstResponder:(resignFirstResponderBlock)block{ dispatch_async(dispatch_get_global_queue(0, 0), ^{ double delayInSeconds = 0.1; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_main_queue(), ^{ [self resignFirstResponder]; block(YES); }); }); return YES; } @end
/***********************************/
使用:
[textField resignFirstResponder:^(BOOL hided) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LoginViewController" bundle:nil];
LoginViewController * loginViewC = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
loginViewC.isAutomaticLogin = YES;
[self.navigationController pushViewController:loginViewC animated:YES];
}];
代码下载:代码下载
相关文章推荐
- UITextField调用resignFirstResponder位置向下移动问题
- ios 使用 resignFirstResponder 无法hide键盘
- UITextField : 如果设置text,然后调用 resignFirstResponder的问题
- Xcode6.0下,UItextfield成为FirstResponder无法呼出键盘的解决
- ,随便点击屏幕任何位子都可以resignFirstResponder,隐藏键盘的两种方法
- firstresponder 后,键盘不显示
- resignFirstResponder
- becomeFirstResponder 不弹出键盘
- UISearchController自动弹出键盘,调用becomeFirstResponder变为第一响应事件
- becomeFirstResponder无法调起键盘
- 解决resignFirstResponder或者endEditing无效的办法
- resignfirstresponder
- UITextField / UIButton / 回收键盘delegate
- iOS_UITextField_回收键盘的几种方法
- first responder与小键盘之间的关系
- textFieldShouldEndEditing 委托导致无法ResignFirstResponder 的一个 Bug
- UITextField点击textField外任意区域键盘回收(一)---- [UIAppllication shareApplication]
- IOS-UITextView、UITextField键盘回收的几种方法
- viewController和resignFirstResponder的情丝
- UITextField的键盘的回收