Git Product home page Git Product logo

hackiftekhar / iqkeyboardmanager Goto Github PK

View Code? Open in Web Editor NEW
16.3K 358.0 2.4K 24.03 MB

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

License: MIT License

Objective-C 17.36% Swift 82.11% Ruby 0.14% C 0.39%
objective-c keyboard swift iqkeyboardmanager xcode

iqkeyboardmanager's Introduction

Icon

IQKeyboardManager

GitHub license

Build Status

While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKeyboardManager allows you to prevent this issue of keyboard sliding up and covering UITextField/UITextView without needing you to write any code or make any additional setup. To use IQKeyboardManager you simply need to add source files to your project.

Key Features

  1. **CODELESS**, Zero Lines of Code

  2. Works Automatically

  3. No More UIScrollView

  4. No More Subclasses

  5. No More Manual Work

  6. No More #imports

IQKeyboardManager works on all orientations, and with the toolbar. It also has nice optional features allowing you to customize the distance from the text field, behaviour of previous, next and done buttons in the keyboard toolbar, play sound when the user navigates through the form and more.

Screenshot

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5

GIF animation

IQKeyboardManager

Video

IQKeyboardManager Demo Video

Tutorial video by @rebeloper (#1135)

@rebeloper demonstrated two videos on how to implement IQKeyboardManager at it's core:

Youtube Tutorial Playlist

https://www.youtube.com/playlist?list=PL_csAAO9PQ8aTL87XnueOXi3RpWE2m_8v

Warning

  • If you're planning to build SDK/library/framework and want to handle UITextField/UITextView with IQKeyboardManager then you're totally going the wrong way. I would never suggest to add IQKeyboardManager as dependency/adding/shipping with any third-party library. Instead of adding IQKeyboardManager you should implement your own solution to achieve same kind of results. IQKeyboardManager is totally designed for projects to help developers for their convenience, it's not designed for adding/dependency/shipping with any third-party library, because doing this could block adoption by other developers for their projects as well (who are not using IQKeyboardManager and have implemented their custom solution to handle UITextField/UITextView in the project).
  • If IQKeyboardManager conflicts with other third-party library, then it's developer responsibility to enable/disable IQKeyboardManager when presenting/dismissing third-party library UI. Third-party libraries are not responsible to handle IQKeyboardManager.

Requirements

Platform iOS

Language Minimum iOS Target Minimum Xcode Version
IQKeyboardManager Obj-C iOS 11.0 Xcode 13
IQKeyboardManagerSwift Swift iOS 13.0 Xcode 13
Demo Project Xcode 15

Swift versions support

Swift Xcode IQKeyboardManagerSwift
5.9, 5.8, 5.7, 5.6 15 >= 7.0.0
5.5, 5.4, 5.3, 5.2, 5.1, 5.0, 4.2 11 >= 6.5.7
5.1, 5.0, 4.2, 4.0, 3.2, 3.0 11 >= 6.5.0
5.0,4.2, 4.0, 3.2, 3.0 10.2 >= 6.2.1
4.2, 4.0, 3.2, 3.0 10.0 >= 6.0.4
4.0, 3.2, 3.0 9.0 5.0.0

7.0.0 version notes

  • In this major release, a lot of variables and functions have been moved here and there. We have mentioned most of the major things in the MIGRATION GUIDE. So please take a look to make changes in your project when upgrading to this version.
  • The 7.0.0 version adopted the latest Swift Concurrency/Actor feature and only available iOS 13.0 and above.
  • Internal keyboard management handling have been updated with a different and better approach than legacy versions. However when adopting 7.0.0, please verify if it is working as expected in your apps, if there are any serious problems with 7.0.0 please open an issue with all the details and switch back to legacy version temporarily.

Installation

Installation with CocoaPods

CocoaPods

IQKeyboardManager (Objective-C): IQKeyboardManager is available through CocoaPods. To install it, simply add the following line to your Podfile: (#9)

pod 'IQKeyboardManager' #iOS13 and later

IQKeyboardManager (Swift): IQKeyboardManagerSwift is available through CocoaPods. To install it, simply add the following line to your Podfile: (#236)

Swift 5.9, 5.8, 5.7, 5.6, 5.5 (Xcode 15)

pod 'IQKeyboardManagerSwift'

Or you can choose the version you need based on Swift support table from Requirements

pod 'IQKeyboardManagerSwift', '6.3.0'

In AppDelegate.swift, just import IQKeyboardManagerSwift framework and enable IQKeyboardManager.

import IQKeyboardManagerSwift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

      IQKeyboardManager.shared.enable = true

      return true
    }
}

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate IQKeyboardManger or IQKeyboardManagerSwift into your Xcode project using Carthage, add the following line to your Cartfile:

github "hackiftekhar/IQKeyboardManager"

Run carthage to build the frameworks and drag the appropriate framework (IQKeyboardManager.framework or IQKeyboardManagerSwift.framework) into your Xcode project based on your need. Make sure to add only one framework and not both.

Installation with Source Code

Github tag

IQKeyboardManager (Objective-C): Just drag and drop IQKeyboardManager directory from demo project to your project. That's it.

IQKeyboardManager (Swift): Drag and drop IQKeyboardManagerSwift directory from demo project to your project

In AppDelegate.swift, just enable IQKeyboardManager.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

      IQKeyboardManager.shared.enable = true

      return true
    }
}

Installation with Swift Package Manager

Swift Package Manager(SPM) is Apple's dependency manager tool. It is now supported in Xcode 11. So it can be used in all appleOS types of projects. It can be used alongside other tools like CocoaPods and Carthage as well.

To install IQKeyboardManagerSwift package via Xcode

Migration Guide

Other Links

Flow Diagram

IQKeyboardManager CFD

If you would like to see detailed Flow diagram then check Detailed Flow Diagram.

LICENSE

Distributed under the MIT License.

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

If you wish to contact me, email at: [email protected]

iqkeyboardmanager's People

Contributors

afrozzaheer avatar agapovone avatar andreybog avatar artfintch avatar bitdeli-chef avatar bj97301 avatar daniil108 avatar ealeksandrov avatar esttorhe avatar hackiftekhar avatar heefanlee avatar hyun99999 avatar iamamused avatar ideviftekhar avatar jacksonjang avatar kgn avatar kinarobin avatar kingslayyerr avatar metinn avatar muzahidul-opti avatar readmecritic avatar retsohuang avatar richardtop avatar rockerhx avatar sadiq81 avatar theoks avatar tizaks avatar toohotz avatar wolfcon avatar yurihan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iqkeyboardmanager's Issues

Localizing Next / Prev buttons.

There is some way to change or localize the text of the Prev / Next button that appears when using the toolbar in IOS 6?
Thanks.

customizing Done button

Is there a way to change title of done button or put and image for the button instead of text, by accessing the button object!?

i just need to change it's name from done to hide. no need to change the functionalty

if i used IQToolbarAddition category methods like addRightButtonOnKeyboardWithText:target:action
i will add my custom button to each textfield..

just thinking of doing this to every text filed give me pain :(

Keyboard dismiss without reseting frame on UITextView (non-editable) text selection

Hi
I'm currently having a bit of a problem with textviews.
I have a UITableView recovering a part of my main view which contains non-editable UITextViews and a small view at the bottom of my screen containing an editable UITextView.

I have set shouldResignOnTouchOutside to false and my main view is a UIScrollView.

The problem is, when I have the focus on my editable UITextView and I want to select some text from another UITextView, keyboard hides but my main view's position won't reset.

I figured this line inside keyboardWillHide:(NSNotification*)aNotification (from IQKeyboardManager.m) is the reason but I didn't find any way to patch it:
if (_textFieldView == nil) return;

Indeed, it seems like selecting text from a non-editable UITextView won't call either UITextViewTextDidBeginEditingNotification or UITextViewTextDidChangeNotification but will call UITextFieldTextDidEndEditingNotification and UIKeyboardWillHideNotification.

I don't know if I am missing something, but I hope you can help me.

Thank you.

In the WebView

if you app has inputfield in the WebView , it can not get the topViewBeginRect of the topMostController ,So when the keyboard hide, the topMostController 's frame will be set to CGRectZero.

EKEventEditViewController & Notes Textview

Hi,

I use your tool in all my project.
My bug is with EKEventEditViewController and the Textview for "Notes"

My view scroll to the end, so far I can't see the text view anymore.

I use :
[[IQKeyboardManager sharedManager] setEnable:YES];
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES];
[[IQKeyboardManager sharedManager] setShouldResignOnTouchOutside:YES];

Any idea?

Social Framework

not sure if this is a bug, but when presenting a SLComposeViewcontroller i get a crash with bounds NaN

Incorrect Toolbar size (Issue #52) when textfield in embedded view controller

In my case the viewController that has the text field on it is a child view controller and is embedded into another one. In this case, the width of toolbar is taken from the child view controller. Why is this even done this way? Toolbar should always be same width as keyboard, regardless of what view controller is presenting it.

How to scroll tableView to it's initial state

I have tableView with 4 custom cells(with textField) and it's height is 44x4. Keyboard moves the textField up. But when the keyboard is hidden, tableView doesn't scroll up.

Does IQKeyboardManager handle this situation or should i use UIKeyboardWillHideNotification

Here is a screenshot:
screen shot 2014-03-23 at 23 29 00

BUG or Issue....

Hello,

First of all I would like to thank you for such a brilliant and nice tool!!
Now, I want to inform you that, in IOS7 but also in IOS6 with ScrollView containing a textview it doesn't work well. The keyboard when comes up scrolls the navigation bar out of view with textview.
I can see only the half bottom part of textview.....
Can you please check and correct?

Thank you very much in advance!

George Gerardis

Issue or Bug with Text View

Hello,

First of all I would like to thank you for such a brilliant and nice tool!!
Now, I want to inform you that, in IOS7 but also in IOS6 with TEXT VIEW it doesn't work well. The keyboard when comes up covers the toolbar ( if one exists ) and scrolls the navigation bar out of view.
Can you please check and correct?

Thank you very much in advance!

George N. Gerardis

Doesn't seem to have any effect

What I did was to copy IQKeyboardManager.h and IQKeyboardManager.m into my project, and in AppDelegate, I changed the didFinishLaunchingWithOptions to be like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [[IQKeyboardManager sharedManager] setEnable:YES];
    return YES;
}

Then I ran my project in both simulator and my iPhone. It doesn't have any effect.

Why SearchBar Do not work?

I have a searchbar, i find that iqkeyboardmanager do not deal mask. but textfield is right. how can i to do ?

Previous, Next, Done button are set to White Color by default ?

Hi Mohd Iftekhar Qurashi,
I would to congratulate for making such an excellent control.
However when i set color using appearance class.

Previous, Next, Done buttons appears in white color.

I have attached screen shot as follows for the same:

ios_simulator_screen_shot_jul_2__2014__11_11_25_am

AppDelegate.m

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
   if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {

    [[UINavigationBar appearance]setBarTintColor:[UIColor whiteColor]];
  [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
    } else {

        [[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];

   }

     [[UINavigationBar appearance]setBackgroundImage:[UIImage  imageNamed:@"invite_friend_notify_bar"] forBarMetrics:UIBarMetricsDefault];


    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            [UIFont fontWithName:@"Helvetica-Light" size:20],  NSFontAttributeName,
                                [UIColor whiteColor], NSForegroundColorAttributeName, nil];

     [[UINavigationBar appearance] setTitleTextAttributes:attributes];


      [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
 }

UI/UX suggestion.

Good and useful library. Thanks!

I think it will be more user-friendly to not to hide navigation bar.
Just make it static and scroll only textfields superview.

Cheers!

conflict with Stripe/PaymentKit

Stripe PaymentKit is a control for collecting credit card numbers. I'd like to use it together with IQKeyboardManager. The conflict is that IQKeyboardManager somehow prevents the PaymentKit from managing its UITextField's frames, resulting in overlapping of words.

I have tried disabling IQKeyboardManager's properties but have no success so far.

BUG or Issue

Hello,

First of all I would like to thank you for such a brilliant and nice tool!!
Now, I want to inform you that, in IOS7 but also in IOS6 with textView it doesn't work well. The keyboard when comes up covers the toolbar ( if one exists ) and scrolls the navigation bar out of view.
Can you please check and correct?

Thank you very much in advance!

George N. Gerardis

NSLog will not ouput

Hi,

I found when I use IQKeyboardManager in my view controller, all the NSLog() cannot give output message, however, when I comment out #import "IQKeyboardManager.h and related IQKeyboard code, my NSLog can give output.

May I know what's the issue? I just use one line [[IQKeyboardManager sharedManager] setEnable:YES]; on UITextView with simplest UIViewController.

Thanks

Not working if I have to login first

Quite wierd problem.

The pod works great if I run the app and I'm already logged in.

If I reset my credentials and either 'register' or 'login' (These views also contain UITextFields but not at the bottom of the app)
Then upon logging in, the IQKeyboardManager is no longer working.

I still get 'Keyboard Manager enabled' at the start of the app.

Problem for iPad's floating keyboard

For iPad,

  1. tap a UITextField on bottom of the screen, the keyboard appears and the whole window moves up.
  2. hold the "Hide keyboard" button in the right bottom corner of keyboard, choose "Undock", the keyboard moves to the middle of screen and the whole window moves down.
  3. click "Done" button on the UISegmentedControl bar. The keyboard moves down.
  4. click above UITextField again.
  5. click "Done" button on the UISegmentedControl bar. The keyboard moves down and the whole window keeps floating a distance above.

bug in new keywindow (custom alertsheet)

When have a new window like custom alertsheet it will some bug
rootViewController and keyWindow should be weak not strong
otherwise keyWindow cannot be release

当有一个新的Window的时候比如自定义带输入框的弹出框,就会有BUG,输入框高度不变,底下的View却被提上去了,另外如果属性不改成weak会造成退出alertView后界面点击不了,无法进行任何操作,因为弹出框的Window不能释放。

@Property(nonatomic, weak, readonly) UIViewController *rootViewController;
@Property(nonatomic, weak, readonly) UIWindow *keyWindow;

-(UIViewController *)rootViewController
{
// if (_rootViewController == nil)
_rootViewController = [[self keyWindow] rootViewController];
return _rootViewController;
}

-(UIWindow *)keyWindow
{
// if (_keyWindow == nil)
_keyWindow = [[UIApplication sharedApplication] keyWindow];
return _keyWindow;
}

this code work for me.
我改成上面的代码后就成功了,不过没有测试对其它功能的影响。理论上没有什么副作用。

Xcode 6/iOS 8 Issues

Currently, when building an application using IQKeyboardManager in Xcode 6 I am running into odd behavior. I have a landscape only application. When the target is set to iOS 8, the window slides to the left rather than up and the keyboard does not appear. When the target is set to iOS 7.0.1, the keyboard does not appear.

Screenshots attached:
xcode6ios8

xcode6ios7

How to handle the return button

Hi,

The previous/next/done buttons in the toolbar works perfectly. However, there is still the return button on the bottom right corner that does not do anything useful. I would like it to behave just like the next button for most fields. I can implement textFieldShouldReturn to handle the return button but I will have to rewrite the logic to move to the next text field. Could you expose something like moveNext in the IQKeyboardManager (basically exposing IQKeyboardManager.nextAction).

Thanks!

No keyboard show on iOS 8

Hi,

I've tried with iOS 8 and see that no keyboard showing. Please check the attached image for more details.

Hope it will be fixed soon.

Cheers,
Hugo

ios simulator screen shot aug 21 2014 15 01 52

I cannot disable the manager

#import < IQKeyboardManager/IQKeyboardManager.h >

 - (void)viewDidLoad{
    [super viewDidLoad];
    [[IQKeyboardManager sharedManager] setEnable:NO];

// All my textfields and UITextViews are in the Interface Builder.

Enable property is just not working...

Next Previuos button doesn't show

I used tableview to create a simple view to register . I used texfield for each cell. But i cannot see next previous button on that.
Can you tell me what am i doing wrond?
ios simulator screen shot feb 3 2014 1 44 28 pm

P.S. It is working well when i use a normal view with textfield.

Setting title for each textField

Hi, i'm trying to set a tittle for the keyboard toolbar for each text field...

I managed to set a fixed title, by adding a UIBarButtonItem between 2 "nilButton"...

What i'm trying to do now is change this title every time the selected textFiled is change, to show, for example, the title "Name" when the name texfield is being filled, "Date" when the date textfield is being filled....

How should i do that ?

Thank you

[iOS 7] UITextField inside UITableViewCell

With iOS7, Apple has changed UITableViewContentView subviews and added a UITableViewCellScrollView. When IQKeyboardManager tries to find the super scrollview, it returns the UITableViewCellScrollView and the UITableView is not scrolled properly.
I can fix this issue by testing the instance type inside the "superScrollView" method

iOS6.0 Memory Leak While Using IQKeyboardManager

Hello hackiftekhar.In my app i am using IQKeyboardManager. Its all working perfectly fine.But when i go for profile testing i am facing memory leak.I was impatient, please fix as soon as possible.Thank you very much!
2014-07-02 4 11 42

Cached toolbars do not respect enabling/disabing textfields

So if you tap into a UITextField and its siblings are disabled, it will not display the move arrows. When those fields are later enabled, the move arrows will still not display. This is because inputAccessoryView field is stored into the UITextField and is only recreated if it is nil.

iOS7 Titelbar Problem

Hi,

when I use this very nice Keyboardmanager under iOS7 a black blank Status Bar stays on top of the screen and pushes the original screen down. This happens, if IQKeyboardManager needs to scrolll the view to allow editing fields which would be covered when the keyboard appears.

Any solution for that issue? My workaround is to hide the titlebar of iOS on all views that need to scroll during textedit.

Set the keyboard language

Hello guys,

Congrats on the great work.

Could you implement an autoswitch of the language - a certain field to open a certain keyboard language. This would be extremely useful for an app where some fields require input in another language.

Many thanks

How to customize inputAccessoryView in IQKeyboardManager?

I need to customize accessory view with the specific background color or want to add some button in keyboard toolbar.

My IQKeyboardManager configuration

[[IQKeyboardManager sharedManager] setEnable:YES];
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES];
[[IQKeyboardManager sharedManager] setShouldResignOnTouchOutside:YES];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.