Swift提供了12种键盘类型:
在开发中,我们可以根据不同的需求,选择不同的键盘样式,例如,当我们只需要输入手机号码时,可以选择纯数字类型的键盘(.NumbersAndPunctuation),当我们需要输入网址时,可以选择URL样式的键盘(.URL),其中,默认的键盘样式(.Default)
我们可以通过输入框的 UIKeyboardType 来设置键盘样式
nameView.textFeild.keyboardType = .numberPad
下面图像将一一展示个个类型的区别
default

numbersAndPunctuation

url

numberPad,asciiCapableNumberPad

phonePad

emailAddress

decimalPad


webSearch

2.取消键盘,如下
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKey)];
[self.tableV addGestureRecognizer:tap];
-(void)closeKey{
[self.tableV endEditing:YES];
}
添加这几行代码即可,tableV是转换成自己的UITableView即可
网友评论