我正在为 iOS 创建一个网络应用程序,并且我有一个自定义键盘。当我使用默认键盘时,它会立即显示键盘,并且文本字段位于键盘上方。如果我将键盘更改为我的自定义键盘,我会得到相同的结果。但问题是我在启用自定义键盘时将焦点放在文本字段上。它有一些延迟加载,当它加载时,文本字段停留在键盘下方。这是我的自定义键盘代码:
#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 类的实现类似于这个库。任何帮助,将不胜感激。