我正在构建一个iOS 8自定义键盘,我希望根据UIKeyboardType更改键盘的布局,但是,在UIInputViewController中读取键盘类型总是0。有什么建议吗?提前感谢!
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
}发布于 2014-10-27 13:24:06
在InputView代理方法中获取InputView,而不是ViewDidLoad。因为在键盘完全显示和输入对象被激活之前,您无法获得keyboardType。
- (void)textWillChange:(id<UITextInput>)textInput {
NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
}或
- (void)textDidChange:(id<UITextInput>)textInput {
NSLog(@"TextInputMode: %ld", self.textDocumentProxy.keyboardType);
}发布于 2014-12-26 10:52:37
(没有足够的代表添加评论对不起)
textDidChange是最好的使用方法,因为在调用keyboardType时已经更新了它。如果你使用textWillChange,你会发现你的键盘落后于一种类型。
https://stackoverflow.com/questions/26579056
复制相似问题