Code Monkey home page Code Monkey logo

dmafwebviewcontroller's Introduction

DMAFWebViewController & DMWebView

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:

DMAFWebViewController

  1. All network activity is mediated by AFNetworking.
  2. self.modifyRequest called before all outgoing requests allowing you to customize requests with a block.
  3. A loading.gif page is displayed automatically and immediately (#define LOADING_GIF, and self.loadingPage)
  4. Page flow control via webView:shouldStartLoadWithRequest:
    • allow loading of self.URL (triggered by loadData:)
    • all other http or https urls will be handed to a new DMAFWebViewController and pushed onto the UINavigationController stack.
    • webview://back pops the current view controller off the stack.
    • all other urls are handed to self.otherSchemeHandler for custom logic.
  5. DOM Manipulation - self.titleTransformer is called (via js) on document.title, and the output has whitespace trimmed.
  6. 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).

DMWebView

  1. setup - self.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
  2. setup - make the background white.
  3. 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.

dmafwebviewcontroller's People

Contributors

coryalder avatar dosgroup avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.