Tuesday, March 15, 2011

iPhone application hurdles

Our API is designed to segregate the database layer from the presentation layer, but we do have a few data items that have html embedded. Our textual job detail and our client about fields require some styling to be embedded, and this presented a new challenge for our iPhone app development.

Fortunately, there is a solution. The UIWebView class is designed to allow embedding of web content within the native app. The class acts much like the i-frame html tag, rendering a view of some external web url within a locally defined rectangle. Navigation of the embedded url content via links or page back calls is also possible. But the class doesn't just allow data from an external url, it will also handle rendering html from a local string via the loadHTMLString method. And that's not all. Since the method has a parameter of the base url for the content, I was able to define the app bundle as the base url. This allows me to embed a line of html defining a css file to control styling, and have that css file reside within the app bundle.

OK, that was a bunch of developer-speak. What does it mean? It means that our content department doesn't have to create iPhone friendly versions of our job descriptions. I can call the API, get the html embedded descriptions, and then style them locally inside the app. I will have to make some modifications to handle link tags differently, but at least we have a solution.

Today I added video playback from our server to the app. This was surprisingly easy to do, as the defined classes are well designed. Now that I think about it, when you don't have to worry about multiple browsers, video isn't all that hard on the web either! I do have a bunch of notification handling code to write to make the application behave well when the video switches to full screen and back, or when the phone is rotated, but I'm happy with the progress.

-Pat Poels

No comments:

Post a Comment