A UIControl
-like API addition to UITextView
.
UITextField
is a UIControl
, so it exposes a target-action interface for various events. UITextView+APSUIControlTargetAction.h
adds the same interface, allowing arbitrary target-actions to subscribe to the following events:
UIControlEventEditingDidBegin
UIControlEventEditingChanged
UIControlEventEditingDidEnd
For example:
#import "ExampleViewController.h"
#import <UITextView+UIControl/UITextView+APSUIControlTargetAction.h>
@interface ExampleViewController ()
@property (nonatomic, strong) UITextView *textView;
@end
@implementation ExampleViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.textView addTarget:self action:@selector(textViewDidChange:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textViewDidChange:(UITextView *)sender
{
NSLog(@"%s, text view text: %@", __PRETTY_FUNCTION__, sender.text);
}
@end
Use CocoaPods and add UITextView+UIControl
to your Podfile
:
pod 'UITextView+UIControl', '~> 0.1.0'
Or install manually by copying everying from Classes/
into your Xcode project.
A big chunk of the work was done during the Back on the Map Objective-c Hackathon.