我正在为iphone 6和6Plus开发自定义键盘。我已经为shift键激活 - 非激活或123和abc键开发逻辑。但我想显示自定义符号,如显示的苹果键盘。请检入图片。
目前我可以将大写更改为小写,将123更改为abc但是如何设置此特殊字符。 注意: - 我在github上搜索了很多演示,但我无法在任何自定义键盘中看到特殊字符。
以下是大写和 ABC-123 按钮的逻辑。
logicalFilter == 1
答案 0 :(得分:2)
你需要两个数组,一个用于alphabetical
,另一个用于numerical
NSArray *NumKey;
NSArray *arrAlphabet;
现在在NumKey
:
NumKey=[[NSArray alloc]initWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"0", @"-", @"/", @":", @";", @"(", @")", @"$", @"&", @"@", @"\"", @".", @",", @"?", @"!",@"'",@"^", nil];
和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
或ABC
。
以编程方式添加事件,如下所示。
[self.keybard.btnNumeric addTarget:self action:@selector(action123:) forControlEvents:UIControlEventTouchUpInside];
将123
更改为ABC
或ABC
更改为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++;
}
}
}
输出:
答案 1 :(得分:1)
我用这种方式设置了问题,因为我也设置了按键图像。
{display:none}