您的位置:首页 > 产品设计 > UI/UE

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];

                

            }];

代码下载:代码下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: