Created
January 6, 2014 19:47
-
-
Save evadne/8288672 to your computer and use it in GitHub Desktop.
Hide UIWebView Keyboard Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation RAEditorView | |
- (instancetype) initWithCoder:(NSCoder *)aDecoder { | |
self = [super initWithCoder:aDecoder]; | |
if (self) { | |
[self setup]; | |
} | |
return self; | |
} | |
- (instancetype) initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) { | |
[self setup]; | |
} | |
return self; | |
} | |
- (void) setup { | |
[self hideKeyboardBar]; | |
} | |
- (void) hideKeyboardBar { | |
static NSString * uniqueSuffix; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
uniqueSuffix = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, CFUUIDCreate(NULL)); | |
}); | |
for (UIView *aView in self.scrollView.subviews) { | |
Class ownClass = [aView class]; | |
NSString *className = NSStringFromClass(ownClass); | |
if (![className hasSuffix:uniqueSuffix]) { | |
NSString *newClassName = [className stringByAppendingString:uniqueSuffix]; | |
Class newClass = objc_allocateClassPair(ownClass, [newClassName UTF8String], 0); | |
if (newClass) { | |
IMP nilImp = [self methodForSelector:@selector(methodReturningNil)]; | |
class_addMethod(newClass, @selector(inputAccessoryView), nilImp, "@@:"); | |
objc_registerClassPair(newClass); | |
} | |
object_setClass(aView, (newClass ?: NSClassFromString(newClassName))); | |
} | |
} | |
} | |
- (id) methodReturningNil { | |
return nil; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment