我想在键盘输入数字键盘时添加一个按钮,但如果是其他类型则删除按钮,如何知道弹出键盘的类型?谢谢。
答案 0 :(得分:1)
您可以尝试这样
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if(textField.keyboardType == UIKeyboardTypeNumberPad)
{
//add your button here
UIButton *button =[[UIButton alloc]initwithFrame:CGRectMake(0, 298, 320, 206)];
[self.view addSubview:button];
}
else
{
//do what you want
[button removeFromSuperView];
}
return YES;
}
在执行此操作之前,请不要忘记将委托添加到Uitextfield