我想找到一种以编程方式触发导致iPhone键盘从字母切换到数字的选择器的方法。我知道我可以切换键盘类型,但我想知道是否有办法在不切换键盘类型的情况下执行此操作。我可以编程方式在iPhone键盘上触发“切换到数字键盘”按钮
回答
您不能以公开支持的任何方式以编程方式切换键盘(字母键盘到数字键盘到符号键盘)。正如您所提到的,您可以更改第一响应者的文本输入特征的键盘类型或外观,但这与在不同的键盘之间切换不同,只有用户应该能够做到。
看一看这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil)
{
cell = [ [ [UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14.0f];
cell.textLabel.textColor = [UIColor whiteColor];
}
UITextField * textField = [ [ UITextField alloc] initWithFrame:CGRectMake(55.0f, 10.0f, 230.0f, 31.0f)];
textField.textColor = [UIColor whiteColor];
textField.delegate = self;
c this care fully ///////////if(indexPath.row == 0)
c this care fully // textField.keyboardType = UIKeyboardTypeDefault;
c this care fully //else
c this care fully // textField.keyboardType = UIKeyboardTypePhonePad;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
[cell.contentView addSubview:textField];
if(indexPath.row == 0)
{
self.sender = textField;
cell.textLabel.text = @"From:";
}
else
{
self.mobileNumber = textField;
cell.textLabel.text = @"To:";
}
[textField release];
if(indexPath.row == 1)
{
UIButton * contactsButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
[contactsButton addTarget:self action:@selector(addContact:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = contactsButton;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
检查,我评论说:“C这个护理完全”
这将帮助你的键盘编程切换。
? – rickharrison 2010-06-07 14:42:58
只是一种变通方法: 当你想在编辑的UITextField活跃键盘的keyplane改变就像从字母到数字键盘,先设置新值文本框的键盘类型物业,未来发送resignFirstResponder,终于成为文本字段的第一个应答消息。例如。
textfield.keyboardType = UIKeyboardTypeNumberPad;
[textField resignFirstResponder];
[textField becomeFirstResponder];
斯威夫特:
textField.keyboardType = .numberPad
textField.resignFirstResponder()
textField.becomeFirstResponder()
希望它可以帮助;-D
应用程序上的任何词语因为这样做而被拒绝? – 2011-08-06 21:36:36
改为使用'textField.reloadInputViews()'! – 2016-12-19 05:12:21
@NikKov'textField.reloadInputViews()'本身不起作用。 – David 2017-08-10 17:52:47
- 1. 以编程方式辞退iPhone键盘
- 2. 以编程方式显示iPhone键盘
- 3. 以编程方式按键盘
- 4. 将完成按钮添加到iPhone上的数字键盘键盘上
- 5. 我可以删除iPad键盘'隐藏键盘'按钮吗?
- 6. 以编程方式在iPhone键盘上对齐工具栏
- 7. 编程键盘上的搜索按钮
- 8. 以编程方式将键盘从大写切换为小写
- 9. Ionic/Cordova:无法以编程方式触发iOS键盘
- 10. 禁用iPhone键盘切换键
- 11. 调换触摸屏键盘按钮[PYTHON]
- 12. 以编程方式取消键盘键盘?
- 13. 在不按键盘按键的情况下触发键盘按键事件
- 14. 键盘输入与可编程键盘
- 15. 如何以编程方式按键盘键?
- 16. 访问键盘列表,键盘切换
- 17. 以编程方式使键盘消失
- 18. 在按钮上方显示键盘
- 19. 如何编写键盘按钮以在两种模式之间切换?
- 20. 使用OK/DONE按钮在Android上以编程方式显示键盘
- 21. 键盘下方的按钮
- 22. 如何在iphone中以编程方式隐藏键盘
- 23. 以可编程方式显示可编辑UIWebView中的键盘
- 24. Swift:以编程方式在键盘上方添加UIButton
- 25. 在键盘可见时,iOS按钮点击不会触发?
- 26. 软键盘按钮
- 27. 以编程方式在Revit中创建键盘快捷键
- 28. 禁用iphone键盘上的数字和标点按钮
- 29. 如何切换iPhone键盘布局?
- 30. 以编程方式打开Android数字键盘
是本作的UIWebView UIView的或一些其他子类?编辑:对不起,只是注意到你的代码中可以修改缩进的uitextfield标签 – conorgriffin 2010-02-28 00:24:59