iOS 用の Web アプリを作成しており、カスタム キーボードを使用しています。デフォルトのキーボードを使用すると、すぐにキーボードが表示され、テキスト フィールドがキーボードの上に表示されます。キーボードをカスタム キーボードに変更しても、同じ結果になります。しかし問題は、カスタム キーボードが有効になっているときに、テキスト フィールドにフォーカスを移すときです。読み込みに多少の遅延があり、読み込み時にテキスト フィールドがキーボードの下に留まります。カスタムキーボードのコードは次のとおりです。
#import "KeyboardViewController.h"
#import "CustomKeyboardView.h"
@interface KeyboardViewController () <CustomKeyboardViewDelegate>
@property (nonatomic, strong) CustomKeyboardView *customKeyboardView;
@end
@implementation KeyboardViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.customKeyboardView = [[CustomKeyboardView alloc] init];
self.inputView = (UIInputView *) self.customKeyboardView;
self.customKeyboardView.delegate = self;
}
- (void)handleCharacter:(NSString *)character sender:(CustomKeyboardView *)sender
{
[self.textDocumentProxy insertText:character];
}
-(void)handelDelete:(CustomKeyboardView *)sender
{
[self.textDocumentProxy deleteBackward];
}
-(void)handleDismissKeyboard:(CustomKeyboardView *)sender
{
[self dismissKeyboard];
}
-(void)handleChangeKeyboard:(CustomKeyboardView *)sender
{
[self advanceToNextInputMode];
}
- (void)textWillChange:(id<UITextInput>)textInput {
// The app is about to change the document's contents. Perform any preparation here.
}
- (void)textDidChange:(id<UITextInput>)textInput {
// The app has just changed the document's contents, the document context has been updated.
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification object:textInput];
}
@end
CustomKeyboardView クラスの実装は、このライブラリに似ています。どんな助けでも大歓迎です。