-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path__HideKeyboardAccessory.m
More file actions
32 lines (26 loc) · 1023 Bytes
/
__HideKeyboardAccessory.m
File metadata and controls
32 lines (26 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
#import <objc/runtime.h>
// Hide keyboard accessory bar in WKWebView
// Based on cordova-plugin-ionic-keyboard approach
__attribute__((constructor))
static void HideKeyboardAccessoryBar(void) {
// Build class name dynamically (WKContentView)
NSString *WKClassString = [@[@"WK", @"Content", @"View"] componentsJoinedByString:@""];
Class WKClass = NSClassFromString(WKClassString);
if (!WKClass) {
NSLog(@"HideKeyboardAccessory: WKContentView class not found");
return;
}
Method WKMethod = class_getInstanceMethod(WKClass, @selector(inputAccessoryView));
if (!WKMethod) {
NSLog(@"HideKeyboardAccessory: inputAccessoryView method not found");
return;
}
// Replace implementation with block that returns nil
IMP newImp = imp_implementationWithBlock(^(id _self) {
return nil;
});
method_setImplementation(WKMethod, newImp);
NSLog(@"HideKeyboardAccessory: Successfully hidden");
}