连接蓝牙键盘时强制屏幕键盘显示

人气:299 发布:2022-10-16 标签: iphone ios4 iphone-sdk-3.0

问题描述

我必须将蓝牙扫描仪连接到我正在开发的应用程序.扫描仪充当键盘输入,但没有键,只有一个按钮用于扫描.我遇到的问题是用户需要在屏幕上与一些 UITextField 进行交互.

I have to have a bluetooth scanner connected to an app I am developing. The scanner acts as a keyboard input but there are no keys, only a button to scan with. The problem I am running into is there are a few UITextFields that a user needs to interact with on the screen.

当用户点击文本框输入数据时,没有键盘弹出,因为 iOS 认为有一个通过蓝牙连接的全键盘.

When the user taps the textfield to enter in data, no keyboard pops up because the iOS thinks there is a full keyboard attached via bluetooth.

如何在 UITextField 成为第一响应者"时强制显示屏幕键盘?

How can I force the screen keyboard to show up when the UITextField "becomes first responder" ?

提前致谢!

推荐答案

问题是蓝牙扫描仪冒充蓝牙键盘,所以iOS认为不需要在屏幕上显示.

The problem is that the Bluetooth scanner is pretending to be a Bluetooth keyboard, so iOS thinks that it doesn't need to show the onscreen one.

不幸的是,这个问题没有简单的答案.一些扫描仪有一个按钮,您可以按下它来强制屏幕键盘出现.有些允许您在iPhone 模式"(或类似模式)下配对,这样它就不会充当蓝牙键盘.

Unfortunately there's no easy answer for this. Some scanners have a button you can press that will force the onscreen keyboard to come up. Some allow you to pair in "iPhone mode" (or something similar) so that it doesn't act as a Bluetooth keyboard.

这个对相关问题的回答(https://stackoverflow.com/a/3837131/493988)有什么似乎是基于 UITextField 的 inputAccessoryView 的 hack,但我没有亲自验证它,所以我不能说太多.祝你好运!

This answer to a related question (https://stackoverflow.com/a/3837131/493988) has what seems like a hack based on a UITextField's inputAccessoryView, but I haven't personally verified it so I can't say much about it. Good luck!

1,000