Third-party libraries that iOS automatically handles keyboard events: Iqkeyboardmanager

Source: Internet
Author: User

We write the interface to consider a lot of user experience problems, keyboard event response is a more troublesome one. We need to listen to keyboard events, consider a click on the background to pick up the keyboard, consider the keyboard occlusion input box problems, and so on, and every interface to do so. This library has helped us to solve this problem.

of this library: Https://github.com/hackiftekhar/IQKeyboardManager

This library is a singleton, and once it comes into effect, any interface to the whole project is valid. The code that makes it work can be written anywhere, I write it in appdelegate.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {        IQKeyboardManager *manager = [IQKeyboardManager sharedManager];    manager.enable = YES;    manager.shouldResignOnTouchOutside = YES;    manager.shouldToolbarUsesTextFieldTintColor = YES;    manager.enableAutoToolbar = NO;        returnYES;}

Enable controls whether the entire feature is enabled.

Shouldresignontouchoutside controls whether the click Background is closed.

Shouldtoolbarusestextfieldtintcolor controls whether the toolbar text color on the keyboard is user-definable.

Enableautotoolbar controls whether the toolbar on the keyboard is displayed.

The above setting, the library is enabled.

Using the method, the code is as follows:

#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong) IQKeyboardReturnKeyHandler    *returnKeyHandler;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];        self.returnKeyHandler = [[IQKeyboardReturnKeyHandler alloc] initWithViewController:self];    self.returnKeyHandler.lastTextFieldReturnKeyType = UIReturnKeyDone;    self.returnKeyHandler.toolbarManageBehaviour = IQAutoToolbarBySubviews;}- (void)dealloc{    self.returnKeyHandler = nil;}@end

To set the Returnkeyhandler, you can click on the next key on the keyboard to automatically jump to the next input box. Last input box click Done to automatically close the keyboard.

After running, you can see that the input box automatically floats up and down as the keyboard pops up. Click on the background and the keyboard is closed. It's fully automatic.

This library is supported by default Uitextfield, Uitextview, UIWebView, Uiscrollview, UITableView,Uicollectionview

Finally, it is important to note that it can automatically calculate the order of multiple TextField, arranged according to the order of the Addsubview.

Third-party libraries that iOS automatically handles keyboard events: Iqkeyboardmanager

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.