IOS keyboard hidden, next textField, keyboard control third-party easy-to-use IQKeyboardManager
Effect
Usage
When using a keyboard, you will often encounter many problems, such as the absence of hidden keyboard and many inconvenient usage. Here we will bring you a third-party library.
IQKeyboardManager * manager = [IQKeyboardManager sharedManager]; manager. enable = YES; // determines whether the entire function is enabled. Manager. shouldResignOnTouchOutside = YES; // controls whether to hide the keyboard on the click background. // controls whether the toolbar text color on the keyboard is customized. shouldToolbarUsesTextFieldTintColor = YES; // controls whether to display toolbar on the keyboard. Manager. enableAutoToolbar = YES;
When we use it, we only need to ensure that these lines of code can be called. We can put it into the appdelegate class for one loading, and then we don't need to change it later, of course, if you make some adjustments, you need to apply new settings. I usually put them in the first class after appdelegate is run, or the place where the keyboard is used for the first time.
Extension:
# Import "ViewController. h "@ interface ViewController () @ property (nonatomic, strong) handler * returnKeyHandler; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; // set returnKeyHandler, you can click the next key on the keyboard to automatically jump to the next input box. In the last input box, Click done to automatically collapse the keyboard. Self. returnKeyHandler = [[IQKeyboardReturnKeyHandler alloc] initWithViewController: self]; self. returnKeyHandler. lastTextFieldReturnKeyType = UIReturnKeyDone; self. returnKeyHandler. toolbarManageBehaviour = IQAutoToolbarBySubviews;}-(void) dealloc {self. returnKeyHandler = nil;} @ end
This library supports many things, such as UITextField, UITextView, UIWebView, UIScrollView, UITableView, and UICollectionView.