meiwin/NgKeyboardTracker
关于
用于在 iOS 应用中跟踪键盘的 Objective-C 库。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文NgKeyboardTracker
Objective-c library for tracking keyboard in iOS apps.
![]()
Adding to your project
If you are using CocoaPods, add to your Podfile:
pod 'NgKeyboardTracker'
To manually add to your projects:
- Add files in
NgKeyboardTrackerfolder to your project. - Add these frameworks to your project:
UIKit.
Features
NgKeyboardTracker encapsulates keyboard tracking for iOS apps.
It provides convenience to query keyboard's properties anywhere in your application.
You can also use NgKeyboardTracker to implement iMessage's text input behavior on iOS 7 (UIScrollViewKeyboardDismissModeInteractive + persistent inputAccessoryView) using NgPseudoInputAccessoryViewCoordinator.
Usage
Start and stop keyboard tracking
In your application delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[NgKeyboardTracker sharedTracker] start]; // start tracking
return YES;
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
[[NgKeyboardTracker sharedTracker] stop]; // stop tracking
}
Responding to keyboard updates
- Implement
NgKeyboardTrackerDelegateprotocol. - Register as delegate by calling
-addDelegate:method - Make sure to call
-removeDelegate:to stop receiving keyboard updates
Keyboard tracker's properties:
appearanceState: current appearance statebeginFrame: last known begin frameendFrame: last known framecurrentFrame: last known current keyboard's frameanimationDuration: last known animation durationanimationCurve: last known animation curveanimationOptions: derived fromanimationCurvefor convenience
P.S. keyboard's frame.size.height system's keyboard height plus inputAccessoryView height.
Pseudo input accessory view coordinator
NgPseudoInputAccessoryViewCoordinator is NgKeyboardTracker extension that makes it easier to implement iMessage's text input behavior in iOS 7 with UIScrollViewKeyboardDismissModeInteractive and persistent inputAccessoryView.
The view controller:
- Override
loadViewto set custom UIView implementation. - Make sure to call the custom view's
becomeFirstResponder.
The custom view:
- Create
NgPseudoInputAccessoryViewCoordinatorby calling-createPseudoInputAccessoryViewCoordinator. - Overrides
-canBecomeFirstResponder, returnsYES. - Overrides
-inputAccessoryView, returns coordinator'spseudoInputAccessoryView. - Set
UIScrollView's keyboard dismiss mode toUIScrollViewKeyboardDismissModeInteractive. - Set desired height of input accessory view with
-setPseudoInputAccessoryViewHeight:. - Layout keyboard's bar accordingly using information from
NgKeyboardTrackerinlayoutSubviews.
P.S. See demo application for example.
探索相关项目
加载中…