gpt4 book ai didi

IOS UISegmentedController 选择键盘

转载 作者:行者123 更新时间:2023-11-29 12:46:45 25 4
gpt4 key购买 nike

是否可以使用 UISegmentedController 来确定用户可用的键盘类型?例如,我希望用户在激活一个段时使用数字键盘,而在激活另一段时使用默认键盘:

if (self.segmentController.selectedSegmentIndex == 1)
{
NSLog(@"Seg1");
[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
//enter numbers

[self resignFirstResponder];
[self.myTextField reloadInputViews];
}
else if (self.segmentController.selectedSegmentIndex == 0)
{
NSLog(@"seg0");
[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeDefault];
// enter words

[self resignFirstResponder];
[self.myTextField reloadInputViews];
}

我确定我遗漏了什么。谁能帮忙?

谢谢

最佳答案

尝试在显示键盘之前设置类型。

改变:

[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];

收件人:

[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
[self.myTextField becomeFirstResponder];

关于IOS UISegmentedController 选择键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23504072/

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