【问题标题】:UITextField Number Pad not workingUITextField 数字键盘不起作用
【发布时间】:2014-02-22 08:51:41
【问题描述】:
_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 文件。

【问题讨论】:

  • 屏幕截图中的键盘仅出现在 iPhone 或 iPod touch 上。在 iPad 上,您将获得全键盘。
  • 所以我必须自己制作小键盘?
  • 不,完整的 iPad 键盘显示数字。

标签: ios keyboard uitextfield


【解决方案1】:

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

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

Apple 在其 Numbers 应用程序中的 iPad 上自定义数字键盘示例:

【讨论】:

  • 所以他们就是这样做的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-11
  • 1970-01-01
  • 2016-04-02
相关资源
最近更新 更多