You take two arrays, one for alphabetical and the other for numerical
NSArray *NumKey; NSArray *arrAlphabet;
Now in NumKey :
NumKey=[[NSArray alloc]initWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"0", @"-", @"/", @":", @";", @"(", @")", @"$", @"&", @"@", @"\"", @".", @",", @"?", @"!",@"'",@"^", nil];
and arrAlphabet :
arrAlphabet = [[NSArray alloc]initWithObjects:@"Q", @"W", @"E", @"R", @"T", @"Y", @"U", @"I", @"O", @"P", @"A", @"S", @"D", @"F", @"G", @"H", @"J", @"K", @"L", @"Z", @"X", @"C", @"V", @"B",@"N",@"M", nil];
IBOutlet in keyBoard 123 or ABC .
Adding an event as programmatically as shown below.
[self.keybard.btnNumeric addTarget:self action:@selector(action123:) forControlEvents:UIControlEventTouchUpInside];
The way to change 123 to ABC or ABC to 123
- (IBAction)action123:(UIButton*)sender { if([self.keybard.btnNumeric.titleLabel.text isEqualToString:@"123"]) { [self.keybard.btnCapital setTitle:@"#+=" forState:UIControlStateNormal]; [self.keybard.btnNumeric setTitle:@"ABC" forState:UIControlStateNormal]; int i=0; for(UIButton *key in self.keybard.keyArray) { key.layer.cornerRadius = 6.0; [key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal]; [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; i++; } } else { [self.keybard.btnCapital setTitle:@"β¬οΈ" forState:UIControlStateNormal]; [self.keybard.btnNumeric setTitle:@"123" forState:UIControlStateNormal]; int i=0; for(UIButton *key in self.keybard.keyArray) { strFirstCap = @"0"; NSString *uppercaseString = [arrAlphabet objectAtIndex:i]; [key setTitle:[uppercaseString lowercaseString] forState:UIControlStateNormal]; [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; i++; } } }
exit:
