Two classes that together form an attempt to make a simple UIWebView to use as in hybrid web/native apps.
Inspired in part by Anne Halsall's appearance on the NSBrief podcast, where she explored some of the ways to use UIWebView for interface elements, without falling into the pitfalls experienced by companies like Facebook.
It is not an attempt to make a full-featured HTML5 app development environemnt, like PhoneGap or Titanium, rather it is a simple view you can use for single-screens of web content. It is intended to be placed in a UINavigationController.
It has the following features / tweaks:
- All network activity is mediated by AFNetworking.
self.modifyRequest
called before all outgoing requests allowing you to customize requests with a block.- A loading.gif page is displayed automatically and immediately (
#define LOADING_GIF
, andself.loadingPage
) - Page flow control via
webView:shouldStartLoadWithRequest:
- allow loading of self.URL (triggered by
loadData:
) - all other
http
orhttps
urls will be handed to a newDMAFWebViewController
and pushed onto theUINavigationController
stack. webview://back
pops the current view controller off the stack.- all other urls are handed to
self.otherSchemeHandler
for custom logic.
- allow loading of self.URL (triggered by
- DOM Manipulation -
self.titleTransformer
is called (via js) ondocument.title
, and the output has whitespace trimmed. - DOM Manipulation -
document.documentElement.style.webkitTouchCallout = "none"
is called (via js) to disable the standard long-press menu (copy/open url/add to reading list).
setup
- self.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;setup
- make the background white.layoutSubviews
- remove the linen that is behind the web view.
My philosophy is that these tweaks should, for the most part, be optional, but with sensible defaults. To that end, all the blocks (self.otherSchemeHandler
, self.titleTransformer
) have defaults set in -init
. There is still some work to do making these tweaks optional and inserting customization blocks, but that's the goal.
MIT licensed.