I have a bluetooth barcode device. If connect the bluetooth device to the iPhone, I can't write anything using iPhone keyboard. you already know that IPhone keyboard does not show on, because the bluetooth device is recognized keyboard.
But!!! I have to write something by keyboard into the textbox while iphone connect with bluetooth device.
Please Let me know how to do that! :) Thanks~
Enable Bluetooth on Mac Without Mouse/Keyboard with Siri Before anything else, if you have Hey Siri enabled on the Mac, there's a super simple solution; you can say “Hey Siri, turn on Bluetooth”. Bluetooth immediately turns on, and the mouse and/or keyboard should connect to the Mac momentarily.
Make sure Bluetooth is turned on Make sure that Bluetooth is turned on. If the Bluetooth icon doesn't appear, or if the menu bar status continues to indicate that Bluetooth is off, restart your computer and then try to turn Bluetooth on again.
We can show device virtual keyboard even when a bluetooth keyboard is connected. We need to use inputAccessoryView
for that.
We need to add below code in app delegate.h
@property (strong, nonatomic) UIView *inputAccessoryView;
add below notifications in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method in delegate.m
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldBegan:) name:UITextFieldTextDidBeginEditingNotification object:nil];
This will call below method when we focus on a textField
.
//This function responds to all `textFieldBegan` editing
// we need to add an accessory view and use that to force the keyboards frame
// this way the keyboard appears when the bluetooth keyboard is attached.
-(void) textFieldBegan: (NSNotification *) theNotification
{
UITextField *theTextField = [theNotification object];
if (!inputAccessoryView) {
inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[inputAccessoryView setBackgroundColor:[UIColor lightGrayColor]];
}
theTextField.inputAccessoryView = inputAccessoryView;
[self performSelector:@selector(forceKeyboard) withObject:nil afterDelay:0];
}
and the code for "forceKeyboard" is,
-(void) forceKeyboard
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
inputAccessoryView.superview.frame = CGRectMake(0, 420, screenHeight, 352);
}
This works fine for us. We use a hidden text field for getting input from bluetooth keyboard and for all other text fields we use device virtual keyboard which is displayed using inputAccessoryView
.
Please let me know if this helps and if you need any more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With