iOS 键盘自适应(IQKeyboardManager)使用小结

2017-03-10  本文已影响98人  进击的小巨牛

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

IQKeyboardManager *manager = [IQKeyboardManager sharedManager];

manager.enable = YES;

manager.shouldResignOnTouchOutside =YES;

[[IQKeyboardManager sharedManager] setToolbarDoneBarButtonItemText:@"确定"];

//    manager.shouldToolbarUsesTextFieldTintColor =YES;

//    manager.enableAutoToolbar = NO;

//    // 最新版的设置键盘的returnKey的关键字 ,可以点击键盘上的next键,自动跳转到下一个输入框,最后一个输入框点击完成,自动收起键盘

manager.toolbarManageBehaviour =IQAutoToolbarByTag;

}

为某一个ViewController禁用IQKeyboardManager

如果你想在某个 viewcontroller 禁用 IQKeyboardManager 你应该在 ViewDidAppear 中禁用IQKeyboardManager,而在ViewWillDisappear启用它

代码:

-(void)viewDidAppear:(BOOL)animated

{

[super viewDidAppear:animated];

_wasKeyboardManagerEnabled = [[IQKeyboardManager sharedManager] isEnabled];

[[IQKeyboardManager sharedManager] setEnable:NO];

}

-(void)viewWillDisappear:(BOOL)animated

{

[super viewWillDisappear:animated];

[[IQKeyboardManager sharedManager] setEnable:_wasKeyboardManagerEnabled];  }  @end

上一篇下一篇

猜你喜欢

热点阅读