1
#import "MyInfoEditTableViewCell.h"
@interface MyInfoEditTableViewCell()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *editField; @end @implementation MyInfoEditTableViewCell
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField == self.editField) {
//这里的if时候为了获取删除操作,如果没有次if会造成当达到字数限制后删除键也不能使用的后果.
if (range.length == && string.length == ) {
return YES;
}
else if (self.editField.text.length >= ) {
self.editField.text = [textField.text substringToIndex:];
return NO;
}
}
return YES;
} - (void)awakeFromNib {
[super awakeFromNib];
self.editField.delegate = self;
} @end