|ReleasedLast Release||Feb 2016|
Maintained by Honghao Zhang.
AutoKeyboardScrollView is a smart UIScrollView which can:
contentViewwhich makes your life with Auto Layout easier
Form views are very common when developing iOS projects. When keyboard is showing up, the big keyboard is covering great areas, which will hide the active textField.
It’s kind of annoying to handle scrolling on UIScrollView and it’s trivial to write keyboard notification and textField target action code again.
To keep your code DRY and make your life with iOS development easier.
AutoKeyboardScrollView.swift (Located in
./Source, right click and Download Linked File) into your project and use it directly.
AutoKeyboardScrollView as parent view of textFields, or views contain textFields. Add subViews on
autoKeyboardScrollView.contentView (Be sure to add subViews on
.contentView), then it just works!
(Note, only textField which is already on the view to be added can be handled, you can manually add textFields that need to be handled by calling
To run the example project, clone the repo, and run
pod install from the Example directory first.
AutoKeyboardScrollView is a subClass of
UIScrollView, some key features are list as following:
A new property:
contentView is added, which is served same purpose as UITableViewCell. All subviews should be added on contentView, this is extremely helpful when dealing Auto Layout with ScrollView (refer: Apple Technical Note TN2154 - UIScrollView And Autolayout)
Note: To let
AutoKeyboardScrollView determine its
contentSize, the height and width of
contentView must be fully specified.
AutoKeyboardScrollView will be attached with a Tap gesture and let you dismiss keyboard by tapping the empty space around textFields.
AutoKeyboardScrollView will automatically detect textFields on newly added subViews, and add UIControlEditing actions for these textField, it will let you dismiss keyboard when tap “Return”.
Create a wrapper view in IB, then add it as a subview on
See example project and select target InterfaceBuilderExample:
Works with Auto Layout, not tested on frame based code.
Support iOS 7 and above. Not tested on iOS 6, since Auto Layout came from iOS6, should be fine.
Honghao Zhang (张宏昊) [email protected]
AutoKeyboardScrollView is available under the MIT license. See the LICENSE file for more info.