Skip to content

UIViewController的一个扩展,添加少量代码,即可完美管理键盘弹出、收回事件

License

Notifications You must be signed in to change notification settings

igiu1988/WYKeyboardObserve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WYKeyboardObserve

A Category for UIViewController that can easily manage keyboard response. image

使用

1.添加observe

viewWillAppera中添加如下方法

[self addObserveKeyboardWithAnimation:^(id controller, CGFloat targeMoveViewEndTop, CGFloat offset, NSString *const notification) {
        // your code
    }];

2. 移除observe

viewWillDisappear 中添加 [self removeObservKeyboard];

3. 在合适的时机设置targetMoveView and referView

targetMoveView: 在键盘将要弹出或者收回时,被移动的view referView: referView.top 会与 keyboard.top 进行对比,以决定targetMoveView是否真的需要移动

Usage

1.Add Observe

add follow code in viewWillAppear

[self addObserveKeyboardWithAnimation:^(id controller, CGFloat targeMoveViewEndTop, CGFloat offset, NSString *const notification) {
        // your code
    }];

2.Remove Observe

add [self removeObservKeyboard]; in viewWillDisappear

3.Set targetMoveView and referView

targetMoveView: the view that view move when keyboard show or hide referView: referView.top will compare to the keyboard.top to determine whether targetMoveView should be moved

About

UIViewController的一个扩展,添加少量代码,即可完美管理键盘弹出、收回事件

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published