Latest 0.1.1
Homepage https://github.com/azu/UITextFieldWithLimit
License MIT
Platforms ios 6.0, requires ARC
Authors

CI Status
Version
License
Platform

This subclass of the UITextField, adds a text length limit.

gif

Feature

  • Set text length limit
  • Text length counter
  • IME support(japanese keyboard support)

Installation

UITextFieldWithLimit is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "UITextFieldWithLimit"

Usage

You can try this : pod try UITextFieldWithLimit

- (void)viewDidLoad {
    [super viewDidLoad];
    self.limitedTextField = [[UITextFieldWithLimit alloc] init];
    self.limitedTextField.maxLength = @15;
    // optional
    self.limitedTextField.limitDelegate = self;
}
- (void)textFieldLimit:(UITextFieldWithLimit *) textFieldLimit didReachLimitWithLastEnteredText:(NSString *) text inRange:(NSRange) range {
    NSLog(@"%s", sel_getName(_cmd));
}

- (void)textFieldLimit:(UITextFieldWithLimit *) textFieldLimit didWentOverLimitWithDisallowedText:(NSString *) text inDisallowedRange:(NSRange) range {
    NSLog(@"%s", sel_getName(_cmd));
}

API

@protocol UITextFieldWithLimitDelegate <UITextFieldDelegate>

@optional
- (void)textFieldLimit:(UITextFieldWithLimit *) textFieldLimit didWentOverLimitWithDisallowedText:(NSString *) text inDisallowedRange:(NSRange) range;

- (void)textFieldLimit:(UITextFieldWithLimit *) textFieldLimit didReachLimitWithLastEnteredText:(NSString *) text inRange:(NSRange) range;
@end

@interface UITextFieldWithLimit : UITextField <UITextFieldDelegate>
@property(nonatomic, strong) id <UITextFieldWithLimitDelegate> limitDelegate;
// Default : @10
@property(readwrite, nonatomic) NSNumber *maxLength;
@property(strong, nonatomic) UILabel *limitLabel;
@end

Author

azu, [email protected]

License

UITextFieldWithLimit is available under the MIT license. See the LICENSE file for more info.

acknowledgment

Latest podspec

{
    "name": "UITextFieldWithLimit",
    "version": "0.1.1",
    "summary": "This subclass of the UITextField, adds a text length limit.",
    "homepage": "https://github.com/azu/UITextFieldWithLimit",
    "screenshots": "http://gyazo.com/469ee2f88953cda723db1ea9744d8ff8.gif",
    "license": "MIT",
    "authors": {
        "azu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/azu/UITextFieldWithLimit.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/azu_re",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes"
}

Pin It on Pinterest

Share This