UITextField数字键盘不起作用

时间:2014-02-22 00:23:47

标签: ios keyboard uitextfield

_text = [[UITextField alloc] initWithFrame:CGRectZero];
        _text.font = [Styles bodyFont];
        _text.text = ((EditTextBubble *)(toEdit.bubble)).textLabel.text;
        if ([_text.text isEqualToString:[@"E.g. " stringByAppendingString:((EditTextBubble *)toEdit.bubble).placeholder]]) _text.text = @"";
        _text.textAlignment = NSTextAlignmentLeft;
        _text.delegate = self;
        _text.userInteractionEnabled = NO;
        [self addSubview:_text];
_text.keyboardType = UIKeyboardTypeNumberPad;

我正在尝试将数字键盘(http://cdn.arstechnica.net/wp-content/uploads/2013/09/keypad.png)用于UITextField,但我得到的只是数字页面上的普通键盘,而不是上面的谷歌图片。你如何让它发挥作用?这是在iOS 7和ipod / ipad上,没有nib文件。

1 个答案:

答案 0 :(得分:2)

如果您需要在iPad上显示小键盘键盘,则需要自行构建(或使用open source),并将文本视图的inputView设置为您创建的视图。但不要惊慌,这很容易做到。

在iOS7上,使用UIInputView获得与原生键盘相似的外观和背景。

Apple的自定义数字键盘在他们的Numbers应用程序中的一个例子:

enter image description here

相关问题