Iqkeyboardmanager GitHub Address: Https://github.com/hackiftekhar/IQKeyboardManager
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
.
-(void)loadView{ 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]; [[IQKeyboardManager sharedManager] setEnable:_wasKeyboardManagerEnabled];}@end
Keyboard return handle 1) Create an instance variable instantiation
IQKeyboardReturnKeyHandler
In
ViewController
Of
viewDidLoad
In
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 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 处理
zero. [email protected] BOOL preventShowingBottomBlankSpace : Prevent to show bottom blanck area when keyboard slide up the view.
IQToolbar
Processing
add the textField‘s placeholder text on IQToolbar. Defaultis YES. @property UIFont *placeholderFont : placeholder Font. Defaultis nil. Defaultis YES.
UITextView
Processing
@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.
UISound
Processing
@property BOOL shouldPlayInputClicks : If YES, then it plays inputClick sound onnext/previous/done click. Defaultis NO.
UIAnimation
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".
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.
IOS keyboard Adaptation (Iqkeyboardmanager) Usage Summary