Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 1.61 KB

README.md

File metadata and controls

57 lines (36 loc) · 1.61 KB

UITextView+UIControl

A UIControl-like API addition to UITextView.

Build Status

Target-Action

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

UITextView target-action screencast

Installation

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.

Attribution

A big chunk of the work was done during the Back on the Map Objective-c Hackathon.