Text field stays under the custom keyboard in UIWebView for iOS 8

我只是一个虾纸丫 提交于 2019-12-25 02:34:47

问题


I'm creating a web App for iOS and I have a custom keyboard. When I use the default keyboard, it immediately shows the keyboard and the text field is above the keyboard. I would have the same result if I change the keyboard to my custom keyboard. But the problem is for the time that I gives the focus to the text field when my custom keyboard is enabled. It has some delay to load and when it loads, text field stays under the keyboard. Here is my code for custom keybaord:

#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

The implementation of CustomKeyboardView class is similar to this library. Any help would be appreciated.


回答1:


Try use the background threads, you have a delay because u execute a lot of code before you build your keyboard view first.



来源:https://stackoverflow.com/questions/25122616/text-field-stays-under-the-custom-keyboard-in-uiwebview-for-ios-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!