简单暴力方法导入IQKeyboardManager第三方库类
使用cocospods 导入 即可实现,点击出现键盘文本框上移的样式
如果在某个页面不需要以上功能只需要加入下面代码
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[IQKeyboardManager sharedManager].enable = NO;
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[IQKeyboardManager sharedManager].enable = YES;
}
或者在Appdelegate里面加入下面代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[IQKeyboardManager sharedManager] disableInViewControllerClass:[ViewController class]];
// Override point for customization after application launch.
return YES;
}
点击回收键盘
- (void)viewDidLoad {
[super viewDidLoad];
[IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
}