UIWebViewis a workhorse of a view. You can use it to display web pages, of course, but you can also use it to display locally-generated rich content.
I was recently using
contentEditableattribute to implement a text field that allows inline images, etc. The fact that I'm using a web view, though, is an implementation detail; to the user, it should just look like any other text field.
UIWebViewloves to show that little "Previous/Next" bar above the keyboard. It was useless and occupying valuable screen space, so I determined to find a way around it.
|This bar is the enemy|
UIWebBrowserView, a private class that does most of the real work. I discovered via
class-dumpthat it also implements
-(id)inputAccessoryView, returning the bar in question. So at runtime, I create a subclass of
UIWebBrowserViewand override that method to return
nil. Then I call
[self reloadInputViews], and I'm done.
I've wrapped this up into a
UIWebViewcategory, which exposes a single property:
@property (nonatomic, assign) BOOL hackishlyHidesInputAccessoryView;
You can find it on gist.
Note: This code has only been tested on iOS 5.1, and may not work on other versions of iOS. I've filed rdar://11040111 requesting a supported way to hide this bar. For now, though, this works, and it should fail gracefully if the internal
UIWebViewview hierarchy changes. If Apple ever releases a supported method for hiding this bar, please use that instead. I only resort to hackery like this when I can find no other option.