简体   繁体   English

在文本字段中显示uipicker而不是键盘

[英]Show uipicker instead of keyboard for textfield

I am trying to hide a keyboard and show up a uipicker instead for textfield. 我试图隐藏键盘并显示uipicker而不是文本字段。

But it seems like I am in the wrong direction or there's something wrong with my coding as the keyboard still persistently show up (uipicker can be seen after another view is bring forward). 但是似乎我走错了方向,或者我的编码有问题,因为键盘仍然不断显示(在提出另一种观点之后才可以看到uipicker)。 I supposed there is nothing wrong with my uipicker methods as the uipicker is showing correctly just that the keyboard is still blocking it. 我认为我的uipicker方法没有问题,因为uipicker可以正确显示,只是键盘仍在阻止它。 Can anyone point out which part of the code went wrong or guide me to the right direction? 谁能指出代码的哪一部分出了问题或将我引向正确的方向?

Here are my codes in the textFieldDidBeginEditing method: 这是我在textFieldDidBeginEditing方法中的代码:

[textField resignFirstResponder];

[pickerView setHidden:NO];

pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 180, 300, 180)];

pickerView.delegate = self;

pickerView.showsSelectionIndicator = YES;

[self.view addSubview:pickerView];

Please let me know if there's is any need for more codes. 如果需要更多代码,请告诉我。

Thanks 谢谢

最简单的方法是将选择器视图设置为文本字段的输入视图:

textField.inputView = pickerView;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM