Ответ 1
Да. Мы сделали это в нескольких наших приложениях, когда у пользователя есть Bluetooth-сканер "клавиатура" в паре с устройством. Что вы можете сделать, так это убедиться, что у вашего текстового поля есть inputAccessoryView, а затем принудительно создайте кадр из InputAccessoryView. Это заставит клавиатуру отображать на экране.
Мы добавили следующие две функции в наш AppDelegate. Переменная 'inputAccessoryView' - это UIView *, который мы объявили в нашем делете приложения:
//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 scanner is attached
-(void) textFieldBegan: (NSNotification *) theNotification
{
UITextField *theTextField = [theNotification object];
// NSLog(@"textFieldBegan: %@", theTextField);
if (!inputAccessoryView) {
inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, navigationController.view.frame.size.width, 1)];
}
theTextField.inputAccessoryView = inputAccessoryView;
[self performSelector:@selector(forceKeyboard) withObject:nil afterDelay:0];
}
//Change the inputAccessoryView frame - this is correct for portrait, use a different
// frame for landscape
-(void) forceKeyboard
{
inputAccessoryView.superview.frame = CGRectMake(0, 759, 768, 265);
}
Затем в нашем приложенииDidFinishLaunching мы добавили этого наблюдателя уведомлений, чтобы мы получили событие в любое время, когда текстовое поле начало редактирование
//Setup the textFieldNotifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldBegan:) name:UITextFieldTextDidBeginEditingNotification object:nil];
Надеюсь, что это поможет!