iOS Class - JJGWebView

For the first few months of my time developing iPhone apps, one of the essential building blocks of most of my apps was a UIWebView—basically, I wanted to be able to open links in-app, rather than open links in Safari (which basically boots the user out of my app—not usually a good thing).

Seeing that there are very disparate articles and postings on the Internet concerning the building of said in-app browsers, I thought I'd develop a class/XIB for iOS that I could reuse across all my apps, rather than build an app-specific browser each time I build a new app.

I haven't seen any other well-documented drop-in UIWebView classes, so I built my own, and tossed it up on GitHub. There may be a rough edge or two, but I've made it pretty painless to be able to integrate JJGWebView (my in-app browser class) with any iPhone App. In fact, I'm using it now on the Catholic STL App, and the Catholic News Live app (among others).

Details

This class/view came about as a result of my wanting to follow best practices for an intuitive in-app browser—one that doesn't have all the functionality of Safari (since that's not needed), but has enough functionality so someone might justifiably stay in your app to follow a thread of links, rather than switch to Safari.

The class also references ShareKit (SHK), which allows for easy sharing of links through various services, or opening links in Safari, or emailing links. Read more about ShareKit here.

Implementation

It's simple to use JJGWebView in your app. Here is a quick run-through:

Implement JJGWebView in your own class; all you have to do is send over a link and a title (or just a link), like so:

In your implementation file, wherever you'd like to push over to the web view (works best inside a Navigation Controller-based app or view), put this at the top, under any other #import statements:

#import "JJGWebView.h"

Then, use this code in your method where someone selects a link (in the demo app, you can see this code in the didSelectRowAtIndexPath method of our table view—you could also use for calloutAccessoryTapped, in a map view):