mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-06-11 08:14:13 +08:00
Update dependencies
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
PODS:
|
||||
- REFormattedNumberField (1.0.4)
|
||||
- REFormattedNumberField (1.1)
|
||||
- REValidation (0.1.4)
|
||||
|
||||
DEPENDENCIES:
|
||||
@@ -7,7 +7,7 @@ DEPENDENCIES:
|
||||
- REValidation
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
REFormattedNumberField: 74ac0f5ce7001102a461dd025d34c93be7794a00
|
||||
REFormattedNumberField: c9f054b837f3c7707fd9b410069b8b0a3a5199da
|
||||
REValidation: 02160035110a63af1bf6ad1b8791837b3fa13584
|
||||
|
||||
COCOAPODS: 0.24.0
|
||||
|
||||
1
RETableViewManagerExample/Pods/BuildHeaders/REFormattedNumberField/NSString+RENumberFormat.h
generated
Symbolic link
1
RETableViewManagerExample/Pods/BuildHeaders/REFormattedNumberField/NSString+RENumberFormat.h
generated
Symbolic link
@@ -0,0 +1 @@
|
||||
../../REFormattedNumberField/REFormattedNumberField/NSString+RENumberFormat.h
|
||||
1
RETableViewManagerExample/Pods/Headers/REFormattedNumberField/NSString+RENumberFormat.h
generated
Symbolic link
1
RETableViewManagerExample/Pods/Headers/REFormattedNumberField/NSString+RENumberFormat.h
generated
Symbolic link
@@ -0,0 +1 @@
|
||||
../../REFormattedNumberField/REFormattedNumberField/NSString+RENumberFormat.h
|
||||
4
RETableViewManagerExample/Pods/Manifest.lock
generated
4
RETableViewManagerExample/Pods/Manifest.lock
generated
@@ -1,5 +1,5 @@
|
||||
PODS:
|
||||
- REFormattedNumberField (1.0.4)
|
||||
- REFormattedNumberField (1.1)
|
||||
- REValidation (0.1.4)
|
||||
|
||||
DEPENDENCIES:
|
||||
@@ -7,7 +7,7 @@ DEPENDENCIES:
|
||||
- REValidation
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
REFormattedNumberField: 74ac0f5ce7001102a461dd025d34c93be7794a00
|
||||
REFormattedNumberField: c9f054b837f3c7707fd9b410069b8b0a3a5199da
|
||||
REValidation: 02160035110a63af1bf6ad1b8791837b3fa13584
|
||||
|
||||
COCOAPODS: 0.24.0
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
// REFormattedNumberField
|
||||
#define COCOAPODS_POD_AVAILABLE_REFormattedNumberField
|
||||
#define COCOAPODS_VERSION_MAJOR_REFormattedNumberField 1
|
||||
#define COCOAPODS_VERSION_MINOR_REFormattedNumberField 0
|
||||
#define COCOAPODS_VERSION_PATCH_REFormattedNumberField 4
|
||||
#define COCOAPODS_VERSION_MINOR_REFormattedNumberField 1
|
||||
#define COCOAPODS_VERSION_PATCH_REFormattedNumberField 0
|
||||
|
||||
// REValidation
|
||||
#define COCOAPODS_POD_AVAILABLE_REValidation
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,12 @@
|
||||
|
||||
UITextField subclass that allows numeric input in a predefined format.
|
||||
|
||||

|
||||
<img src="https://github.com/romaonthego/REFormattedNumberField/raw/master/Screenshot.png?2" alt="REFormattedNumberField Screenshot" width="320" height="568" />
|
||||
|
||||
## Requirements
|
||||
* Xcode 4.5 or higher
|
||||
* Xcode 5 or higher
|
||||
* Apple LLVM compiler
|
||||
* iOS 5.0 or higher
|
||||
* iOS 6.0 or higher
|
||||
* ARC
|
||||
|
||||
## Demo
|
||||
@@ -19,7 +19,7 @@ Build and run the `REFormattedNumberFieldExample` project in Xcode to see `REFor
|
||||
### CocoaPods
|
||||
|
||||
The recommended approach for installating `REFormattedNumberField` is via the [CocoaPods](http://cocoapods.org/) package manager, as it provides flexible dependency management and dead simple installation.
|
||||
For best results, it is recommended that you install via CocoaPods >= **0.15.2** using Git >= **1.8.0** installed via Homebrew.
|
||||
For best results, it is recommended that you install via CocoaPods >= **0.24.0** using Git >= **1.8.0** installed via Homebrew.
|
||||
|
||||
Install CocoaPods if not already available:
|
||||
|
||||
@@ -39,8 +39,8 @@ $ edit Podfile
|
||||
Edit your Podfile and add REFormattedNumberField:
|
||||
|
||||
``` bash
|
||||
platform :ios, '5.0'
|
||||
pod 'REFormattedNumberField', '~> 1.0.4'
|
||||
platform :ios, '6.0'
|
||||
pod 'REFormattedNumberField', '~> 1.1'
|
||||
```
|
||||
|
||||
Install into your Xcode project:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NSString+RENumberFormat.h
|
||||
// REFormattedNumberFieldExample
|
||||
//
|
||||
// Created by Roman Efimov on 9/13/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (RENumberFormat)
|
||||
|
||||
- (NSString *)re_stringWithNumberFormat:(NSString *)format;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// NSString+RENumberFormat.m
|
||||
// REFormattedNumberFieldExample
|
||||
//
|
||||
// Created by Roman Efimov on 9/13/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSString+RENumberFormat.h"
|
||||
|
||||
@implementation NSString (RENumberFormat)
|
||||
|
||||
- (NSString *)re_stringWithNumberFormat:(NSString *)format
|
||||
{
|
||||
if (self.length == 0 || format.length == 0)
|
||||
return self;
|
||||
|
||||
format = [format stringByAppendingString:@"X"];
|
||||
NSString *string = [self stringByAppendingString:@"0"];
|
||||
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\D" options:NSRegularExpressionCaseInsensitive error:NULL];
|
||||
NSString *stripped = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, string.length) withTemplate:@""];
|
||||
|
||||
NSMutableArray *patterns = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *separators = [[NSMutableArray alloc] init];
|
||||
[patterns addObject:@0];
|
||||
|
||||
NSInteger maxLength = 0;
|
||||
for (NSInteger i = 0; i < [format length]; i++) {
|
||||
NSString *character = [format substringWithRange:NSMakeRange(i, 1)];
|
||||
if ([character isEqualToString:@"X"]) {
|
||||
maxLength++;
|
||||
NSNumber *number = [patterns objectAtIndex:patterns.count - 1];
|
||||
number = @(number.integerValue + 1);
|
||||
[patterns replaceObjectAtIndex:patterns.count - 1 withObject:number];
|
||||
} else {
|
||||
[patterns addObject:@0];
|
||||
[separators addObject:character];
|
||||
}
|
||||
}
|
||||
|
||||
if (stripped.length > maxLength)
|
||||
stripped = [stripped substringToIndex:maxLength];
|
||||
|
||||
NSString *match = @"";
|
||||
NSString *replace = @"";
|
||||
|
||||
NSMutableArray *expressions = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSInteger i = 0; i < patterns.count; i++) {
|
||||
NSString *currentMatch = [match stringByAppendingString:@"(\\d+)"];
|
||||
match = [match stringByAppendingString:[NSString stringWithFormat:@"(\\d{%ld})", (long)((NSNumber *)[patterns objectAtIndex:i]).integerValue]];
|
||||
|
||||
NSString *template;
|
||||
if (i == 0) {
|
||||
template = [NSString stringWithFormat:@"$%li", (long)i+1];
|
||||
} else {
|
||||
template = [NSString stringWithFormat:@"%@$%li", [separators objectAtIndex:i-1], (long)i+1];
|
||||
}
|
||||
replace = [replace stringByAppendingString:template];
|
||||
[expressions addObject:@{@"match": currentMatch, @"replace": replace}];
|
||||
}
|
||||
|
||||
NSString *result = [stripped copy];
|
||||
|
||||
for (NSDictionary *exp in expressions) {
|
||||
NSString *match = [exp objectForKey:@"match"];
|
||||
NSString *replace = [exp objectForKey:@"replace"];
|
||||
NSString *modifiedString = [stripped stringByReplacingOccurrencesOfString:match
|
||||
withString:replace
|
||||
options:NSRegularExpressionSearch
|
||||
range:NSMakeRange(0, stripped.length)];
|
||||
|
||||
if (![modifiedString isEqualToString:stripped])
|
||||
result = modifiedString;
|
||||
}
|
||||
return [result substringWithRange:NSMakeRange(0, result.length - 1)];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -24,12 +24,16 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NSString+RENumberFormat.h"
|
||||
|
||||
@interface REFormattedNumberField : UITextField
|
||||
|
||||
@property (copy, readwrite, nonatomic) NSString *format;
|
||||
@property (copy, readonly, nonatomic) NSString *unformattedText;
|
||||
|
||||
- (NSString *)string:(NSString *)string withNumberFormat:(NSString *)format;
|
||||
// Use NSString category NSString+RENumberFormat
|
||||
// - (NSString *)re_stringWithNumberFormat:(NSString *)format;
|
||||
//
|
||||
- (NSString *)string:(NSString *)string withNumberFormat:(NSString *)format __attribute__ ((deprecated));
|
||||
|
||||
@end
|
||||
|
||||
@@ -48,71 +48,41 @@
|
||||
|
||||
- (NSString *)string:(NSString *)string withNumberFormat:(NSString *)format
|
||||
{
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\D" options:NSRegularExpressionCaseInsensitive error:NULL];
|
||||
NSString *stripped = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, string.length) withTemplate:@""];
|
||||
if (!string)
|
||||
return @"";
|
||||
|
||||
NSMutableArray *patterns = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *separators = [[NSMutableArray alloc] init];
|
||||
[patterns addObject:@0];
|
||||
|
||||
NSInteger maxLength = 0;
|
||||
for (NSInteger i = 0; i < [format length]; i++) {
|
||||
NSString *character = [format substringWithRange:NSMakeRange(i, 1)];
|
||||
if ([character isEqualToString:@"X"]) {
|
||||
maxLength++;
|
||||
NSNumber *number = [patterns objectAtIndex:patterns.count - 1];
|
||||
number = @(number.integerValue + 1);
|
||||
[patterns replaceObjectAtIndex:patterns.count - 1 withObject:number];
|
||||
} else {
|
||||
[patterns addObject:@0];
|
||||
[separators addObject:character];
|
||||
}
|
||||
}
|
||||
|
||||
if (stripped.length > maxLength)
|
||||
stripped = [stripped substringToIndex:maxLength];
|
||||
|
||||
NSString *match = @"";
|
||||
NSString *replace = @"";
|
||||
|
||||
NSMutableArray *expressions = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSInteger i = 0; i < patterns.count; i++) {
|
||||
NSString *currentMatch = [match stringByAppendingString:@"(\\d+)"];
|
||||
match = [match stringByAppendingString:[NSString stringWithFormat:@"(\\d{%d})", ((NSNumber *)[patterns objectAtIndex:i]).integerValue]];
|
||||
|
||||
NSString *template;
|
||||
if (i == 0) {
|
||||
template = [NSString stringWithFormat:@"$%i", i+1];
|
||||
} else {
|
||||
template = [NSString stringWithFormat:@"%@$%i", [separators objectAtIndex:i-1], i+1];
|
||||
}
|
||||
replace = [replace stringByAppendingString:template];
|
||||
[expressions addObject:@{@"match": currentMatch, @"replace": replace}];
|
||||
}
|
||||
|
||||
NSString *result = [stripped copy];
|
||||
|
||||
for (NSDictionary *exp in expressions) {
|
||||
NSString *match = [exp objectForKey:@"match"];
|
||||
NSString *replace = [exp objectForKey:@"replace"];
|
||||
NSString *modifiedString = [stripped stringByReplacingOccurrencesOfString:match
|
||||
withString:replace
|
||||
options:NSRegularExpressionSearch
|
||||
range:NSMakeRange(0, stripped.length)];
|
||||
|
||||
if (![modifiedString isEqualToString:stripped])
|
||||
result = modifiedString;
|
||||
}
|
||||
return result;
|
||||
return [string re_stringWithNumberFormat:format];
|
||||
}
|
||||
|
||||
- (void)formatInput:(UITextField *)textField
|
||||
{
|
||||
__typeof (&*self) __weak weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
textField.text = [weakSelf string:textField.text withNumberFormat:_format];
|
||||
});
|
||||
if (textField.text) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
textField.text = [self.unformattedText re_stringWithNumberFormat:self.format];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteBackward
|
||||
{
|
||||
NSInteger decimalPosition = -1;
|
||||
for (NSInteger i = self.text.length - 1; i > 0; i--) {
|
||||
NSString *c = [self.text substringWithRange:NSMakeRange(i - 1, 1)];
|
||||
|
||||
BOOL valid;
|
||||
NSCharacterSet *alphaNums = [NSCharacterSet decimalDigitCharacterSet];
|
||||
NSCharacterSet *inStringSet = [NSCharacterSet characterSetWithCharactersInString:c];
|
||||
valid = [alphaNums isSupersetOfSet:inStringSet];
|
||||
if (valid) {
|
||||
decimalPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (decimalPosition == -1) {
|
||||
self.text = @"";
|
||||
} else {
|
||||
self.text = [self.text substringWithRange:NSMakeRange(0, decimalPosition)];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)unformattedText
|
||||
|
||||
@@ -713,11 +713,11 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = E4370D63D1564228A75E7BD2 /* Pods.xcconfig */;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "RETableViewManagerExample/RETableViewManagerExample-Prefix.pch";
|
||||
INFOPLIST_FILE = "RETableViewManagerExample/RETableViewManagerExample-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos7.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@@ -729,11 +729,11 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = E4370D63D1564228A75E7BD2 /* Pods.xcconfig */;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "RETableViewManagerExample/RETableViewManagerExample-Prefix.pch";
|
||||
INFOPLIST_FILE = "RETableViewManagerExample/RETableViewManagerExample-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos7.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
||||
Reference in New Issue
Block a user