• Stars
    star
    203
  • Rank 192,144 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The best view dodger for inputting.

MLInputDodger

License MIT  CocoaPods  CocoaPods  Build Status  Apps Using  Downloads 

My library does not seek any reward, but if you use this library, star it if you like. :)

MLInputDodger

Advantage

  • Automatic processing of keyboard-related events with little code, not affect global and no special view or viewController nee to be inherited, so it's flexible.
  • Provide a optional default retractButton which can be clicked to hide keyboard.
  • Use animateAlongsideBlock to add your own dodge behaviors for other views or to trigger other behaviors.
  • With transition complete of two vc, the dodge behavior would be triggered again, ensure dodge behavior.
  • Fixed iOS8's bug: UIKeyboardFrameEndUserInfoKey return strange origin.y sometimes.
  • Fixed SougouInput's bug: it produces a ungly spring animation sometimes.

Principle

  • The dodgeView means which view need to be change frame or change contentOffset(contentInset)
  • All subviews which can becomeFirstResponder in the dodgeView will trigger the dodge behavior.
  • The inputView of subviews maybe not only keyboard. It's ok, this is why the library named MLInputDodger not MLKeyboardDodger. :)

Usage

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    self.view.shiftHeightAsDodgeViewForMLInputDodger = 50.0f;
    [self.view registerAsDodgeViewForMLInputDodgerWithOriginalY:self.view.frame.origin.y];
}

Then the subviews which can becomeFirstResponder will trigger dodge.
If you need custom shiftHeight for special responder, just set the shiftHeightAsFirstResponderForMLInputDodger property.

Disbale default retract input accessory view:

self.view.dontUseDefaultRetractViewAsDodgeViewForMLInputDodger = NO; //for all subviews of self.view

self.testView1.dontUseDefaultRetractViewAsFirstResponderForMLInputDodger = NO; //for sepecial

AnimateAlongside:

[[MLInputDodger dodger]setAnimateAlongsideBlock:^(BOOL show,UIView *dodgerView,UIView *firstResponderView,CGRect inputViewFrame) {
        if ([dodgerView isKindOfClass:[UIScrollView class]]) {
            ((UIScrollView*)dodgerView).scrollIndicatorInsets = ((UIScrollView*)dodgerView).contentInset;
        }
    }];
__weak __typeof(self)weakSelf = self;
    [self.tableView setAnimateAlongsideAsDodgeViewForMLInputDodgerBlock:^(BOOL show,UIView *dodgerView,UIView *firstResponderView,CGRect inputViewFrame) {
        __strong __typeof(weakSelf)sSelf = weakSelf;
        CGRect frame = sSelf.testAnimateAlongsideLabel.frame;
        if (show) {
            frame.origin.y = inputViewFrame.origin.y+kMLInputDodgerRetractViewDefaultHeight-kLabelBottomMargin-kLabelHeight;
        }else{
            frame.origin.y = sSelf.view.frame.size.height-kLabelBottomMargin-kLabelHeight;
        }
        sSelf.testAnimateAlongsideLabel.frame = frame;
    }];

Tips

You can add this category to disable automatic keyboard for UITableViewController, or it will affect the implementation of the library. But _adjustForAutomaticKeyboardInfo:animated:lastAdjustment: is a private api, so...

@implementation UITableView(DisableAutomaticKeyboard)
- (void)_adjustForAutomaticKeyboardInfo:(id)arg1 animated:(BOOL)arg2 lastAdjustment:(float*)arg3 {
    return;
}
@end

More Repositories

1

MLEmojiLabel

Automatic URL recognition and custom expression like wechat
Objective-C
803
star
2

MLLabel

UILabel replacement with TextKit. Support link and expression.
Objective-C
724
star
3

MLTransition

iOS7+, pop ViewController with pan gesture from middle or edge of screen.
Objective-C
452
star
4

MLLayout

Flexbox in Objective-C, using Facebook's css-layout.
Objective-C
251
star
5

MLAutoReplace

Xcode plugin which help you write code faster.
Objective-C
232
star
6

MLAudioRecorder

练手之作,实现不怎么样,可能存在问题,也不继续维护,所以注意仅供参考学习。
Objective-C
181
star
7

MLNavigationBarTransition

Advanced navigation bar transition based on official push-pop transition
Objective-C
78
star
8

MLPresentController

Present ViewController with custom animator. support interactiving with UIPanGestureRecognizer
Objective-C
55
star
9

MLMultiSelectViewController

multi select contact like wechat group
Objective-C
43
star
10

MLImageCrop

image crop ,custom ratio , can rotate - 图片截取,可以自定义截取比例,支持旋转
Objective-C
31
star
11

MLIgnoreTransparentButton

a button can ignore touch of transparent area and a uiview category can auto set mask with image.
Objective-C
9
star
12

MLAudio

MLAudio - 暂时请勿关注,方便自己使用的玩意。
Objective-C
7
star
13

Arm64InspectiveC

Based on InspectiveC. Print on console. No theos/tweak/cycript depend.
Objective-C++
4
star
14

MLActivityView

ActivityView Like WeChat - 类似微信的ActivityViewController
Objective-C
4
star
15

jsoniterpb

Replacement of Protojson over Jsoniter Extension
Go
3
star
16

MLKit

自用,暂请勿关注
Objective-C
3
star
17

gopit

golang大坑集锦
Go
3
star
18

MLActionSheet

ActionSheet - 类似Instagram的
Objective-C
2
star
19

MLDataSyncPool

simple data sync pool
Objective-C
2
star
20

MLRefreshControl

Refresh control for UIScrollView
Objective-C
2
star
21

zlib

zlib cgo wrapper
Go
1
star
22

MLAlipaySDK

方便使用罢了 请勿关注~~~!!!!!
Objective-C
1
star
23

MLSmoothCorner

smooth using for corner of UIView
Objective-C
1
star
24

MLHttpDNS

Objective-C
1
star