Skip to content

andrewsardone/UITextView-UIControl

Repository files navigation

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.

About

A UIControl-like API addition to UITextView

Resources

License

Stars

Watchers

Forks

Packages

No packages published