Fork me on GitHub
Home

DLWebView - a drop-in browser component

24 April 2011

A couple of weeks ago, I had to implement a browser component in 4 different Apps at work. I went through the hassel of implementing it separately each time, although they basically had the same requirements. Last weekend I went the extra mile to bake a component, which you can use in your code, in case you need to display a website.

Hello World - DLWebView!

DLWebView is a UIViewController subclass, which you can use in conjunction with a UINavigationController. It features a refresh button, back/forward buttons as well as a title label. Those buttons are added to the UINavigationBar, when DLWebView is loaded.

If you add a UIBarButtonItem to DLWebView, when setting up the UINavigationController and hook it up to

- (IBAction)showUrlField:(id)sender;

and you’ll get a flashy UITextField to handle editing URLs. However, if you only have one website to display, it’s not mandatory to enable this feature.

DLWebView works in portrait and in landscape mode (check out the video above). Once a page is loading, you can see the URL displayed in the title, which changes to the title of the website once loaded completly. It’s iOS 3.x compatible, so no worries about breaking exisiting Apps.

There’s still some stuff to work on:

I’d love for folks out there to help me make this a first-class component to use, when you need to display websites in your App.


// other posts