1、
正则,RegexKitLite是用的最多的,DP4用不了考虑降级到4.3||尝试修复,修好发pull request||向作者提feature request试试看,虽然此框架两年没更新了。
还有内建的正则实现,我来一段检查字符串是否是合法的中国手机号的正则匹配:
- (BOOL)isValidChinesePhoneNumber
{
    NSString *Regex =@"(13[0-9]|14[57]|15[012356789]|18[02356789])\\d{8}";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
    return [predicate evaluateWithObject:self];
}2、
_textView 后来我改成 textView 了,和 @property 对应好的。
重构改名两个都会被改(xcode的bug)
同样的问题存在于:
//重构一个方法,另一个也会跟着改名,xcode的bug
- (void)test;
+ (void)test;
3、
我修改过的类如下,看下是否满足需求:
.h
#import <UIKit/UIKit.h>
@interface TestViewController : UIViewController<UITextViewDelegate>
@end
.m:
#import "TestViewController.h"
@interface TestViewController ()
@property (strong, nonatomic) UIScrollView *scrollView;
@property (strong, nonatomic) UITextView *textView;
@end
@implementation TestViewController
@synthesize scrollView = _scrollView, textView = _textView;
- (void)viewDidLoad 
{
    [super viewDidLoad]; // Do any additional setup after loading the view.
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    self.scrollView.backgroundColor = [UIColor greenColor];
    self.scrollView.contentInset = UIEdgeInsetsMake(1, 0, 0, 0);
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    self.textView.scrollEnabled = NO;
    self.textView.delegate = self;
    
    [self.scrollView addSubview:self.textView];
    [self.view addSubview:self.scrollView];
    
    [self resizeTextView];
}
- (void)resizeTextView 
{
    CGRect frame = self.textView.frame;
    frame.size.height = self.textView.contentSize.height;
    [self.textView setFrame:frame];
    [self.scrollView setContentSize:frame.size];
    if (frame.size.height > self.scrollView.frame.size.height)
    {
        [self.scrollView setContentOffset:CGPointMake(0, frame.size.height - self.scrollView.frame.size.height) animated:YES];
    }
}
- (void)textViewDidChange:(UITextView *)textView
{
    [self resizeTextView];
}
@end5.0下测试,4.3可能会有刚进入编辑状态顶部漂移问题,楼主先试试看