Skip to content

Instantly share code, notes, and snippets.

@evadne
Created January 6, 2014 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evadne/8288672 to your computer and use it in GitHub Desktop.
Save evadne/8288672 to your computer and use it in GitHub Desktop.
Hide UIWebView Keyboard Bar
@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