代码:
- (void)viewDidLoad {
[super viewDidLoad];
// NSArray *myArr = [NSArray arrayWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg",@"6.jpg",@"7.jpg", nil];
//
// NSUInteger count = [myArr count];
// for (int index = 0 ; index<count; index++) {
// [self layoutSubImage:myArr[index] withX:50*(index%3) withY:50*(index/3)];
// }
_aField.delegate = self;
[_aField addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textFieldChanged:(UITextField *)aTextField{
aTextField.text = [aTextField.text uppercaseString];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSCharacterSet *set = [[NSCharacterSet characterSetWithCharactersInString:ALLCHARACTERS] invertedSet];
NSString *upperStr = [string uppercaseString];
NSString *filted = [[upperStr componentsSeparatedByCharactersInSet:set] componentsJoinedByString:@""];
NSLog(@"string>>>%@,fileted>>>%@",string,filted);
BOOL allowed = [upperStr isEqualToString:filted];
return allowed;
}