MADismissiveTextView
is a drop-in UITextView
subclass that handles dismissing the keyboard with your finger, just like in the Messages.app.
MADismissiveTextView
is designed to be used in tandem with a UIScrollView
as well as its UIPanGestureRecognizer
. As such, this class only works with iOS 5.0 and up.
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, 320, 416)]; [self.view addSubview:scrollView]; MADismissiveTextView *textView = [[MADismissiveTextView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; textView.dismissivePanGestureRecognizer = scrollView.panGestureRecognizer; textView.keyboardDelegate = self; [self.view addSubview:textView];
The MADismissiveKeyboardDelegate
protocol allows you to make changes to your UI at key moments during the animation of the UIKeyboard
. These delegate methods are all optional.
- (void)keyboardDidShow; - (void)keyboardDidScroll:(CGPoint)keyboardOrigin; - (void)keyboardWillBeDismissed; - (void)keyboardWillSnapBack;