gpt4 book ai didi

iPhone SDK : How to determine keyboard type within a UIKeyboardDidShowNotification?

转载 作者:行者123 更新时间:2023-12-03 19:14:47 24 4
gpt4 key购买 nike

我需要知道当前的键盘类型。我正在设置一个实例变量

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField

但是,测试表明,由于通知的异步性质,这并不总是可靠。

我想知道是否有人可以告诉我如何确定当前的键盘类型通知?

- (void)keyboardDidShow:(NSNotification *) {
// Need way to determine keyboard type here
}

谢谢。

最佳答案

如果您询问键盘的语言,只能在iOS4.2及以上版本中使用 UITextInputMode class 来完成方法:+[UITextInputMode currentInputMode];

如果您想要简单的大小(因为大小可能会根据语言而改变),请从键 UIKeyboardBoundsUserInfoKey 的对象中获取大小

- (void)keyboardWasShown:(NSNotification*)aNotification{
NSDictionary* info = [aNotification userInfo];
NSValue* aValue = [info UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;
//I just got the size! ... do something with it
}

关于iPhone SDK : How to determine keyboard type within a UIKeyboardDidShowNotification?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4635261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com