【问题标题】:iOS 8 custom keyboard extension UIKeyboardTypeiOS 8 自定义键盘扩展 UIKeyboardType
【发布时间】:2014-10-26 23:14:07
【问题描述】:

我正在构建一个 iOS 8 自定义键盘,我想根据 UIKeyboardType 更改键盘的布局,但是,在 UIInputViewController 中读取的键盘类型始终为 0。 有什么建议么?提前致谢!

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
}

【问题讨论】:

    标签: ios8 ios-app-extension


    【解决方案1】:

    在 InputView 委托方法中获取 keyboardType 而不是 ViewDidLoad 。因为在键盘完全呈现并激活输入对象之前,您无法获取keyboardType。

    - (void)textWillChange:(id<UITextInput>)textInput {
    
        NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
    
    }
    

    - (void)textDidChange:(id<UITextInput>)textInput {
    
        NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
    
    }
    

    【讨论】:

      【解决方案2】:

      (没有足够的代表添加评论抱歉)

      textDidChange 是最好的方法,因为在调用它时,keyboardType 已经更新。如果你使用textWillChange,你会发现你的键盘落后了一个类型。

      【讨论】:

      • 这对我有帮助!谢谢!
      猜你喜欢
      • 1970-01-01
      • 2016-04-06
      • 2014-08-11
      • 2014-12-19
      • 2015-05-30
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多