IOS keyboard Adaptation (Iqkeyboardmanager) Usage Summary

Source: Internet
Author: User

Iqkeyboardmanager GitHub Address

Often in the development of an application, we encountered a problem with the iphone's keyboard sliding overlay UITextField / UITextView . You IQKeyboardManager can prevent keyboard slippage problems and overrides UITextField / UITextView without having to enter any code, without requiring additional setup requirements. With Iqkeyboardmanager you just need to add the source files to your project.

Key Features

1) No Code
2) Automatic operation
3) No moreUIScrollView
4) No more sub-classes
5) No more manual work
6) No More#imports


Iqkeyboardmanager Support CocoaPods

Pod ' Iqkeyboardmanager '

Management

Uinavigationbar

If you don't use storyboard or xib create your view. You need to override -(void)UIViewController loadview the method and need to set an UIScrollView instance self.view .



UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
self.view = scrollView;
}
Disable for one Viewcontroller IQKeyboardManager

If you want to disable in some of the viewcontroller IQKeyboardManager you should disable ViewDidAppear IQKeyboardManager it while in the ViewWillDisappear enable it
Code:

#import "IQKeyboardManager.h"@implementationExampleViewController  BOOL _wasKeyboardManagerEnabled;}-(void)viewDidAppear:(BOOL)animated{    [super viewDidAppear:animated];    _wasKeyboardManagerEnabled = [[IQKeyboardManager sharedManager] isEnabled];    [[IQKeyboardManager sharedManager] setEnable:NO];}-(void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];    @end


Keyboard return handle 1) Create an instance variable instantiation IQKeyboardReturnKeyHandlerIn ViewControllerOf viewDidLoadIn

Code:

@implementationViewController { IQKeyboardReturnKeyHandler *returnKeyHandler;}- (void)viewDidLoad{    [super viewDidLoad];    returnKeyHandler = [[IQKeyboardReturnKeyHandler alloc] initWithViewController:self];}

Change the return key on the keyboard.

Dealloc method to set the instance variable to zero
-(void)dealloc {    returnKeyHandler = nil;}
Uitoolbar (Iqtoolbar) 1) If you do not want to add a specific auto toolbar above the keyboard, you should add a class as its toolbar
textField.inputAccessoryView = [[UIView alloc] init];
2) If you need to control the up/down/Finish button yourself, then you should use the UIView class method to create your text box toolbar.

Code:

-(void) viewdidload{[Super Viewdidload];    //Adding done button for textField1   [textField1 addDoneOnKeyboardWithTarget:self action:@selector(doneAction:)];      //Adding previous/next/done button for textField2   [textField2 addPreviousNextDoneOnKeyboardWithTarget:self previousAction:@selector(previousAction:) nextAction:@selector(nextAction:) doneAction:@selector(doneAction:)];     //Adding cancel/done button for textField3   [textField3 addCancelDoneOnKeyboardWithTarget:self cancelAction:@selector(cancelAction:) doneAction:@selector(doneAction:)];    /*! previousAction. */  -(void)previousAction:(id)button   //previousAction     /*! nextAction. */  -(void)nextAction:(id)button   //nextAction     /*! doneAction. */  -(void)doneAction:(UIBarButtonItem*)barButton   //doneAction     /*! cancelAction. */  -(void)cancelAction:(UIBarButtonItem*)barButton  //cancelAction   }


function and use UIKeyboard 处理
+(instancetype)sharedManager : Returns the default singleton instance.@property BOOL enable : Use this to enable/disable managing distance between keyboard & textField/textView).@property CGFloat keyboardDistanceFromTextField : Set Distance between keyboard & textField. Can‘t be less than zero. [email protected] BOOL preventShowingBottomBlankSpace : Prevent to show bottom blanck area when keyboard slide up the view.
IQToolbarProcessing
@property BOOL enableAutoToolbar : Enable autoToolbar behaviour. If It is set to NO. You have to manually create UIToolbar for keyboard. Defaultis YES.@property IQAutoToolbarManageBehaviour toolbarManageBehaviour : Setting toolbar behaviour to IQAutoToolbarBySubviews to manage previous/next according to UITextField‘s hierarchy in it‘s SuperView. Set it to IQAutoToolbarByTag to manage previous/next according to UITextField‘s tag propertyin increasing order. Defaultis IQAutoToolbarBySubviews.@property BOOL shouldToolbarUsesTextFieldTintColor : If YES, then uses textField‘s tintColor propertyfor IQToolbar, otherwise tintColor is black. Defaultis NO. @property BOOL shouldShowTextFieldPlaceholder : If YES, then it add the textField‘s placeholder text on IQToolbar. Defaultis YES. @property UIFont *placeholderFont : placeholder Font. Defaultis nil. Defaultis YES.
UITextViewProcessing
@property BOOL canAdjustTextView : Giving permission to modify TextView‘s frame. Adjust textView‘s frame when it is too big in height. Defaultis NO.@property BOOL shouldFixTextViewClip : Adjust textView‘s contentInset to fix fix for iOS 7.0.x -(#Stackoverflow). Defaultis YES.
Uikeyboard Appearance Overlay
@property BOOL overrideKeyboardAppearance : Override the keyboardAppearance for all textField/textView. Defaultis NO.@property UIKeyboardAppearance keyboardAppearance : If overrideKeyboardAppearance is YES, then all the textField keyboardAppearance issetusing this property.
Shut down UITextField/UITextView
@propertyBOOL shouldResignOnTouchOutside : Resign textField if touched outside of UITextField/UITextView.-(void)resignFirstResponder : Resigns currently first responder field.
UISoundProcessing
@property BOOL shouldPlayInputClicks : If YES, then it plays inputClick sound onnext/previous/done click. Defaultis NO.
UIAnimation
@property BOOL shouldAdoptDefaultKeyboardAnimation : If YES, thenuses keyboard default animation curve style to move view, otherwise uses UIViewAnimationOptionCurveEaseOut animation style. Defaultis YES.
Characteristics

1) Support device orientation.
2) When you enable/disable the keyboard message, you need to set enable the Boolean value.
3) Simple integration.
4) as a textField/textView AutoHandle UIToolbar Boolean value that needs to be set enableAutoToolbar .
5) can be used by the parent view AutoHandle UIToolbar or by textField/textView using toolbarManageBehaviour enumerations.
6) Easy to add up and down and complete button keyboard UIToolbar UIView class, automatically use enableAutoToolbar Boolean values.
7) Enable/Disable the method of the next/Previous button class, using the enableAutoToolbar boolean value automatically.
8) keyboard settings are used from the text box keyboardDistanceFromTextField .
9) keyboard touch outside with shouldResignOnTouchOutside. disable.
10) Manage the frame when the UITextView height is too large, use the canAdjustTextView settings to fit the screen.
11) applicable in UITableView/UIScrollView theUITextField/UITextView
12) You can enter the sound when you click "Next/Previous page/Finish".

Extended reading:

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

The above describes the iOS keyboard Adaptive (Iqkeyboardmanager) Usage summary, including the aspects of the content, I hope that the development of iOS interested friends are helpful.

This article site link: http://www.codes51.com/article/detail_117701.html

IOS keyboard Adaptation (Iqkeyboardmanager) Usage Summary

Related Article

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.