iOS 8自定义键盘扩展UIKeyboardType [英] iOS 8 custom keyboard extension UIKeyboardType

查看:244
本文介绍了iOS 8自定义键盘扩展UIKeyboardType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm building a iOS 8 custom keyboard and I'd like the change the layout of the keyboard based on the UIKeyboardType, however, reading the keyboard type in UIInputViewController is always 0. Any suggestions? Thanks in advance!

- (void)viewDidLoad
{
    [super viewDidLoad];

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


推荐答案

获取 keyboardType 在InputView Delegate方法而不是ViewDidLoad中。因为在键盘完全呈现并且输入对象被激活之前你无法获得keyboardType。

Get the keyboardType in InputView Delegate Methods Instead of ViewDidLoad . Because you can't get the keyboardType until The keyboard is fully presented and the input object is activated .

- (void)textWillChange:(id<UITextInput>)textInput {

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

}

OR

- (void)textDidChange:(id<UITextInput>)textInput {

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

}

这篇关于iOS 8自定义键盘扩展UIKeyboardType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆