webview调用系统键盘后隐藏键盘上方功能键

在当前类的最前面加上

//隐藏webview调用键盘之后 的 功能键:比如完成

@interfaceUIWebView (HackishAccessoryHiding)

@property(nonatomic,assign)BOOLhidesInputAccessoryView;

@end

@implementationUIWebView (HackishAccessoryHiding)

static const char * const hackishFixClassName = "UIWebBrowserViewMinusAccessoryView";

staticClasshackishFixClass =Nil;

- (UIView*)hackishlyFoundBrowserView {

    UIScrollView *scrollView = self.scrollView;


    UIView*browserView =nil;

    for(UIView*subviewinscrollView.subviews) {

        if ([NSStringFromClass([subview class]) hasPrefix:@"UIWebBrowserView"]) {

            browserView = subview;

            break;

        }

    }

    returnbrowserView;

}

- (id)methodReturningNil {

    return nil;

}

- (void)ensureHackishSubclassExistsOfBrowserViewClass:(Class)browserViewClass {

    if (!hackishFixClass) {

        ClassnewClass =objc_allocateClassPair(browserViewClass,hackishFixClassName,0);

        newClass =objc_allocateClassPair(browserViewClass,hackishFixClassName,0);

        IMPnilImp = [selfmethodForSelector:@selector(methodReturningNil)];

        class_addMethod(newClass,@selector(inputAccessoryView), nilImp,"@@:");

        objc_registerClassPair(newClass);


        hackishFixClass= newClass;

    }

}

- (BOOL) hidesInputAccessoryView {

    UIView *browserView = [self hackishlyFoundBrowserView];

    return[browserViewclass] ==hackishFixClass;

}

- (void) setHidesInputAccessoryView:(BOOL)value {

    UIView *browserView = [self hackishlyFoundBrowserView];

    if(browserView ==nil) {

        return;

    }

    [self ensureHackishSubclassExistsOfBrowserViewClass:[browserView class]];


    if(value) {

        object_setClass(browserView,hackishFixClass);

    }

    else{

        ClassnormalClass =objc_getClass("UIWebBrowserView");

        object_setClass(browserView, normalClass);

    }

    [browserViewreloadInputViews];

}

@end

之后:

_webView.hidesInputAccessoryView = YES;//隐藏键盘上方功能键

你可能感兴趣的:(webview调用系统键盘后隐藏键盘上方功能键)