美文网首页
iOS 键盘自适应(IQKeyboardManager)使用小结

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

作者: 进击的小巨牛 | 来源:发表于2017-03-10 21:53 被阅读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

    相关文章

      网友评论

          本文标题:iOS 键盘自适应(IQKeyboardManager)使用小结

          本文链接:https://www.haomeiwen.com/subject/pfiogttx.html