10 Tips for New iPhone WebApp Developers

10 Tips for New iPhone Developers

Making a webapp for the iPhone is a lot like making a normal web site, but with a few quirks to abide by. In this article, I’ll give you a wide variety of tips, covering things such as: “must-haves”, usability guidelines, testing/debugging, pitfalls, and performance issues. I hope you enjoy it!

WebApps vs. Native Apps

Keep in mind that a web application runs in the browser, while a native application is installed on the iPhone.
So, if you want to make something like a high-performance, fast-responsive, action-packed game with awesome graphics, then you’re probably better
off just learning Objective-C and making a native app. However, if you don’t own a Mac and/or if you are trying to do something a lot simpler, like
making a mobile version of your website or blog, then making a web app might be the faster and more reasonable road to take.

Still not convinced? Here are a list of popular sites that are iPhone web apps/websites:

The list goes on…
If you’re REALLY smart, you’ll make BOTH a native app(hopefully free) and web app, like most of the sites above did.

1: Viewport, Viewport, Viewport

I would say this may be the simplest and most important thing for an iPhone web app. It’s just one line of code to include within your head tags:

	<!-- add this in your <head> section with your other meta tags-->
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />

This tells the browser to scale your page in such a way that will make it fit nicely on the iPhone. Here’s what each field means:

  • width=device-width
    This fits the page to the device’s width. The iPhone’s display is 320×480 pixels in portrait mode, and 480×320 pixels in landscape mode, which is why you sometimes see sites use width=320 instead of width=device-width.
  • initial-scale=1.0
    This is the scaling when the page first loads up.
  • maximum-scale=1.0
    This is the maximum scaling allowed.
  • user-scalable=0
    This determines whether the user is allowed to zoom in and out by pinching/double-tapping. You can also use user-scalable=no and user-scalable=yes instead of 0 and 1.

Keep in mind that the viewport IS NOT A WINDOW. Think of it like a magnifying glass over a page. You can move the magnifying glass around and zoom in/out.
This is why certain features like fixed positioning don’t work on the iPhone(at least at the time of this writing). In Professional iPhone and iPod touch Programming, Richard Wagner explains what a viewport is:

A viewport is a rectangular area of screen space within which an application is displayed. Traditional
Windows and Mac desktop applications are contained inside their own windows. Web apps are displayed
inside a browser window. A user can manipulate what is seen inside of the viewport by resizing the
window, scrolling its contents, and in many cases, changing the zoom level.

Specifying the viewport is a *must-have* and is the first step into making your web app iPhone-friendly.

2: "Hide" the Address Bar!

The address bar takes up a considerable portion of the already tiny screen we have to work with. You’ll want to hide the address bar to display as much information on the screen as you can, so that the user doesn’t have to flick down. Consider the picture below. Is that the whole screen, or is there more information below?

With the address bar
With the address bar

Now let us hide the address bar by adding this single line of javascript code:

//add this in your javascript code to 'hide' the address bar
window.scrollTo(0, 1);

This will "hide" the address bar by scrolling down just enough so that you won’t see it when loading the page. In our picture below, we see that there was more information to be displayed after all!

Without the address bar
Without the address bar

Notice that this only temporarily hides the address bar by just scrolling down a bit upon loading the page. Permanently hiding the address bar may not be the best idea, but it is possible. For safety’s sake, we’ll leave that outside of the scope of this article.

3: Test on iPhone AND Browsers

Although your ultimate goal is to put your web app on the iPhone, testing it on normal browsers can be beneficial!

Remember, since this is a web application, you can test it like one! That means useful tools like Firebug, Web Developer, and YSlow still work!

Using Firebug to Test/Debug your iPhone web app
"A firebug error!? But that’s impossible…my code is always perfect!"

NOTE: You may get errors for certain pieces of code that are legitimate — iPhone-specific/webkit-specific code mostly. With that said, don’t be too dependent on these tools…they are more of a guide, not an oracle.

Keep in mind also that Firefox may display things differenty than Safari does, and Safari is also different from Mobile Safari. You’ll most certainly notice web apps that you develop in Dashcode won’t display properly on Firefox.
This is why you still need to test on an iPhone. If you do however, develop in Dashcode, there are testing/debugging features that come with it.

4: Mimic a Native App if Possible

From a usability perspective, making your web app look like a native iPhone app is beneficial because users already know how to use an iPhone application, thus there is a positive transfer of knowledge.
Besides that, using the buttons, font, lists, etc is also beneficial. A lot of time and money was put into researching what would be a good design…Apple must have hired various usability and design experts.
If you mimic a native app, you won’t have to go through the whole process of designing and creating something that may in the end prove infeasible.

Take a look at the picture below…this is the "Groups" menu from the "Contacts" feature. Can you guess whether this is the real deal(native app), or a fake(webapp mimic)?

Is this a native app or web app?
Native app or web app?

If you guessed that the above pic is a web app, you are correct! See how closely you can mimic a native app?

If you do not wish to mimic a native iPhone web app, perhaps because your application doesn’t fit well that way or because you want to maintain your style, then at least follow some basic guidelines:

  • Be consistent (i.e: navigation buttons on each page)
  • Make buttons large enough to tap (i.e: for fat fingers or the error-prone)
  • Make things intuitive (i.e: collapsible boxes should have hint…like a +/- next to it)

5: Use Frameworks, Libraries, and Tools to Save Time

If you do decide to mimic a native app, then I suggest not starting from scratch. There are many things out there that can save you a ton of time:


  • Dashcode

    If you have a Mac, this may be the best route to go if you want to whip up something fast. Dashcode has a parts library(i.e: buttons/frames), a code snippets library, a workflow steps guide, and way more!
  • iUI
    Created by Joe Hewitt, this nice little framework lets you create web apps with simple HTML! It has a nice slide-effect too. Performance is FAST and the framework itself is very tiny filesize-wise.
  • iWebkit
    Just like iUI, you can create your app with simple HTML. However, this framework has many features that other frameworks might not have. It also comes with a user guide which clearly explains how to use the features.
    What makes this my favorite framework is that it plays nice with other javascript code, so I can customize my web app and do things like make collapsible boxes

There are, of course, many other frameworks, libraries, and tools, but as to date, these are my favorite ones. Have one that you really like? Write it in the comments below!

iWebkit popup
iWebkit‘s pop-up feature

6: Use Lists When Possible

Lists are a nice quick n’ dirty way of displaying information. "Contacts" and "Mail" display information in the form of lists. Lists allow for easy navigation, let you display a lot of items on the tiny screen, and are easy to touch compared to pictures.
They also load pretty fast since they’re just text. Lists will almost always be your navigation method of choice, but then again it really depends on what your web app is.

If you do use a list, grouping items by alphabet, relevance, or usage is always a good way to go.

An alphabetical list
A list with items grouped by alphabet

7: Minimize Horizontal Navigation

If possible, minimize the number of screens your users have to navigate to in order to get the information they want.
Having less pages to jump to means less redirecting and unnecessary loading by going backwards and forewards.

Many screens
Many navigation screens

In the example picture above, we can possibly eliminate the first two screens by automatically getting the date/time and start out with the third screen.
If a user wants to intentionally pick and different day/time, we can have that in the "Change View" menu.

8: Make Your App Small and Fast

Remember that performance is critical in the mobile world, as a user may be on the EDGE network or just have a slow connection. Give them as little to download as possible! Just like normal web sites, the same rules of enhancing performance apply. Instead of
giving you a checklist of everything, I would just recommend that you get both Page Speed and YSlow, as these
give more detailed checklists on beefing up performance than I could ever give.

iui filesize
Not bad for a framework that has a .js file, a .css file, and a bunch of images, huh?

9: Have a Homescreen Icon

Make sure to have a nice icon that people can see when they add your web app to their homescreen. Make a 57×57 PNG file and add the following code to your home page:

	<!-- add this in your <head> section -->
    <link href="path/to/your/icon.png" rel="apple-touch-icon" />

Having an icon is a good way to quickly recognize your web app, as well as look professional while having some nice eye-candy.

10: iPhone ‘Simulators’ aren’t Perfect

You will notice that iPhone simulators, even the official "Aspen Simulator", can sometimes yield different results than on the iPhone. This is true even when making native apps. This should actually be somewhat expected since the iPhone OS is different from Mac OS and the iPhone architecture is different from a normal computer. I want people to know about this, because I’ve had quite a few friends
develop and test mainly on "simulators" only to find out near final production/deployment that their program on the iPhone was buggy, crashed, or simply just didn’t work. Please be careful when using a simulator–they are here for convenience, NOT for iPhone replacement. Remember that since your ultimate goal is to put something on the iPhone, then test on the iPhone. Since you are making a web app and not a native app, you won’t need to worry about paying the developer fee or becoming a registered developer with Apple.

simulator FAIL
Simulator FAIL

Conclusion

I hope you enjoyed this article! One of the joys of making a web app is you can develop on any platform! I tried to keep the tips as cross-platform as possible. However, although this is true, it still might be the best idea to develop on a Mac.

There are many other important tips that I did not mention here, simply because other people have beaten me to the punch! If you are really serious about iPhone web app development, go out there and learn more! There are plenty of resources that your best friend
can give you that I would not know about.

Have any tips of your own? Want to call me out on tips that are nonsense? Share your knowledge by writing in the comments below! I love learning new things and I definitely want to be corrected if I am wrong.


Tags: mobile
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Drazen Mokic

    Thanks, nice infos.

  • Drazen Mokic

    @ Is there coming a Tutorial today?

  • http://www.quizzpot.com crysfel

    It is time to develop for the iphone :D

  • Shaun

    Decent tips. I’m sure it will be helpful to a lot of people.

  • http://www.demogeek.com DemoGeek

    This couldn’t come up at a better time than when I’m getting my hands dirty with XCode and ObjC. Perfect timing (at least for me!). Thank you!

  • http://www.weebee.be Falco

    Nice Post. If you want to see an example with iUI framework, I develop a web app on Formula One. Go to http://iphone.weebee.be

    It’s a great framework, very easy to use.

    • Paolo Ranoso
      Author

      Very nice!! I checked this out and I am very impressed with the initial loading time, considering how many pictures you put on this! Very well done!

      -paolo

  • http://www.davidkaneda.com/ David Kaneda

    I also wrote a similar Javascript framework for emulating native apps, based on jQuery, called jQTouch:
    http://www.jqtouch.com/

    It has quite a few advantages over other libraries as well, like hardware animations, different transition types, and loads of callback events.

  • http://pixelwarrior.org Nelson Zheng

    Is there a way to code and compile Objective C on windows platform?

    • http://blerz.com jeff

      no – you need an intel based mac

    • http://armchairdetectives.com Ian

      gcc can compile Objective C. Cygwin has gcc for Windows. Go get it and go nuts.

      The biggest problem will be that Apple doesn’t make Cocoa or their other SDKs available for Windows. The obviously use it in house (iTunes for Windows) but they don’t make it available to the public.

      This may help you:
      http://stackoverflow.com/questions/113547/iphone-development-on-windows

      Short answer: you can’t, legally. You can if you jailbreak your iPhone and go down that road.

      A mac mini is a cheap, legal way to get started.

      • http://blerz.com jeff

        Well, assuming he was asking about writing Obj-C for the purposes of making IPhone apps – no, you cannot use windows. Sorry, no if ands or buts, you cannot. If you just want to mess around with objective c for the sake of it, of course you could install cygwin (if youre a masochist), or somethig else. But cocoa touch is not an SDK, it is a framework only available on mac hardware – are the Iphone SDK uses the cococa touch framework to create iphone apps.
        Jailbreaking your phone will allow you to install 3rd party apps, and write iphone apps that mimic native apps with javascript tricks etc – but if you want to write a real, native iphone app, you need a mac, with an intel proc. No other way.

      • http://pixelwarrior.org Nelson Zheng

        Thanks!
        Yeah… I think I might be lazy and just fork out some extra cash for an Apple Laptop or something.

  • http://myfacefriends.com Myfacefriends

    nice tuts! thanks

  • http://www.dennisplucinik.com Dennis Plucinik

    This should have been titled “10 Tips for New iPhone Web App Developers”. That aside, this is a great checklist to keep on hand when getting into a new project.

    Thanks!

  • Paolo Ranoso
    Author

    Thanks for the warm comments and motivation everyone!

    @David Kaneda: Hahah yes! I was actually considering using your framework for one of my projects since I love jQuery. Is the alpha 2 version your final release? I believe this will be a huge hit once good documentation comes out for it.

    @Nelson Zheng: I don’t have much knowledge on this topic, but by doing a quick google search, the first two things that popped up for me may be helpful for you:
    http://blog.lyxite.com/2008/01/compile-objective-c-programs-using-gcc.html
    http://www.roseindia.net/iphone/objectivec/objective-c-windows.shtml
    I wouldn’t recommend this unless you really know what you are doing, as the official way of doing this would be on a Mac using XCode with the iPhone SDK(and of course to download the iPhone SDK you need to become an Apple-registered developer, which is free)

  • http://blerz.com jeff

    This is not Iphone development in the normal sense. Please note people, you cannot sell or distribute webapps via the Apple App Store

  • Drazen Mokic

    @ David Kaneda

    Is it based on Joe Hewitts iUI Framework? http://code.google.com/p/iui/

    • http://www.davidkaneda.com/ David Kaneda

      It was originally — but has grown to leverage a few jQuery-specific features (like callbacks), which I think make it more powerful. It’s currently in alpha status — most the of the scripting is complete, I just need to wrap up the interface bits (just recently switched out a few images in favor of -webkit-gradient, for example)

  • Kris

    super cool article. i really enjoyed it for a few reasons: 1) very helpful 2) well-organized with great examples 3) you sort of look like mario lopez :)

    • Paolo Ranoso
      Author

      Lol Thanks Kris,

      It is said that the cure to cancer is found in Mario Lopez’s dimples.

  • Paolo Ranoso
    Author

    @DemoGeek: Glad you found this helpful!

    Please keep in mind though that these tips are mainly for iPhone web apps…if you are making a native app, then most of these won’t apply to you, but yes, you could make use of the usability/navigation/simulator tips(tips 6, 7, & 10).

    -paolo

  • http://www.johndeszell.com John Deszell

    Thanks for this information. I picked up a 3G S on launch day and have been wanting to toy with developing sites and things for it.

    Thanks!

  • http://labs.dariux.com Dario Gutierrez

    Excellent tut Paolo.

  • Paolo Ranoso
    Author

    Thanks for the warm comments everyone!!

    @David Kaneda: Ahh yes! I was actually considering using your framework for one of my projects since I love using jQuery! Is Alpha 2 version your final version? I think jQTouch will make it big once good, detailed documentation comes out.

    @DemoGeek: I’m glad you found this helpful! Keep in mind though, that this article was mainly for web apps for the iPhone. If you are making a native app, most of these tips won’t apply, but you could still make use of the usability/simulation tips (tips 6, 7, & 10).

    @Nelson Zheng: I don’t have much knowledge in this area, but after a quick google search I found these two that you might find helpful:
    http://blog.lyxite.com/2008/01/compile-objective-c-programs-using-gcc.html
    http://www.roseindia.net/iphone/objectivec/objective-c-windows.shtml
    I wouldn’t recommend this stuff unless you really know what you are doing, since the official way(at least right now), is to do everything on a Mac in XCode with the iPhone SDK. In order to download the iPhone SDK you will need to become an Apple-registered developer(which is free).

  • Dels

    is there any simulator i can try for Windows platform?

  • Ricardo

    nice tips!
    thanks

  • http://pixelspring.co.uk Mike

    Jeff McFadden’s Magic Framework is also worth a look:
    http://www.jeffmcfadden.com/projects/Magic%20Framework/

  • http://galaxydesign.com.au Sam

    thanks mate… the javascript and framework tips are awesome!

  • http://www.brucelawson.co.uk bruce
  • http://www.crearedesign.co.uk Martyn Web

    Ive been looking to start iphone development myself and have downloaded the sdk to get started but I would really like some good step by step or video tutorials just to get my head around the way it works.

    Any ideas?

    Thanks

    • Paolo Ranoso
      Author

      Hi Martyn,

      Are you making a native app? Keep in mind these tips are for web apps.

      If you decide to go down the native app road, I would start here:

      http://developer.apple.com/iphone/

      That is Apple’s official site for developing for the iPhone. They have tutorials/vids/articles/etc…they even have a tutorial on learning Objective-C!

      This all assumes that you have a Mac. If you don’t have a Mac, then you may want to do a web app, since there is currently at this time, no legitimate or easy way to do it on other platforms.

      • Paolo Ranoso
        Author

        *err making a native app that is…sorry. That last paragraph refers to native apps.

      • http://www.crearedesign.co.uk Martyn Web

        Yeah I have a mac and I’m a pretty good web designer / xhtml/css but I really just want to learn how to build apps such as things or tearoundapp.

        Do i need to concentrate on objective c and the coca touch ( thats it or c++ as well?

  • http://www.mooncatvetures.com michelle

    Nice post I agree on some parts and disagree on others. I think some people jumped on the native apps a little too quick. Some tasks are more suited to web applications.

    I think the best way to do it though is crossover hybrids between the two.

    http://sol3.typepad.com/tagalong_developer_journa/2009/06/the-problems-with-mobile-applications.html

    http://www.mooncatventures.com/blogs

    we hope to have a couple apps out in August that take full advantage of sdk 3.0

  • http://www.help2career.com Rishi

    Excellent tut.

  • http://astroot.info astroot

    Great tips!

    One resource I found pretty helpful while developing an iPhone-specific site was the actual resources from Apple.

    The Safari Reference Library, specifically, was pretty good. I’d recommend going through that stuff. Can’t remember if you can get to it without signing up for an account, but regardless, it’s free to sign up for an account if necessary.

    This document, Optimizing Web Content for the iPhone, helped quite a bit.

    http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html

  • http://www.nouveller.com/ Benjamin Reid

    I’m definitely going to try this out, I love mimicing UI’s! :D

  • http://www.upsidelearning.com Amar

    Nice post. Thanks for info. We have also developed one cost effective IPhone application. The process has been explained on our Blog. Also we can use PhoneGap framework to develop cross mobile platform web application.

  • http://www.utopiestudio.co.uk/ Matt Liverpool

    BOOKMARKED!!! Man, alls I need now is a bloody iPhone!!!

  • http://www.theiphonedevelopers.co.uk Application Developers

    Great list – iwebkit is definitly one of the best frameworks out there in terms of ease of use, feature sets etc.

  • http://www.sdplabs.com Anna

    Great post,
    Applications cannot work everywhere, an iPhone app would work only on iPhone and not on blackberry or any other. This is why i think that iPhone compatable websites (like m.digg.com) are a better in comparison to applications. Cost effective, work on every platform, Just a browser needed, and so many benefits. And after some googling this is what i got:
    ‘Made for iPhone’ websites by SDPlabs makes it even simpler and easier to have a iPhone compatible website. So now anyone can have a iPhone website.
    Hope that helps someone.

  • http://www.tapeten-express.de Checkkk

    thank u 4 this

  • http://www.xbuzz.com Chris

    Excellent Article. Keep up the great work.

  • http://www.tapeten-news.de MAt

    I try this out :D

  • http://www.phonefreelancer.com iphone developer

    Great article for basic iphone app design. When you get into game design and stuff like that it gets a lot harder. But this article shows you an excellent place to start. Highly recommended.

  • shupid

    Thank you . Good Post!

  • http://www.m65jacket.com m65

    good read thanks a lot for the share

  • http://pixert.com Kate Mag

    Wow, thanks for this article. It’s very helpful and easy :)

  • http://www.igorsbrezinskis.com Igors Brezinskis

    Thanks for the post! I think these skills- must have. I am going make website mobile friendly aswell! =)

  • Miked

    Hello,
    Great list of steps to hopefully get me started towards a nice web app.. thankyou.
    I was wondering if anyone knows a way of side sliding…. like when going through the icon pages on your iphone/touch? I was thinking that in some cases sliding across instead of down can be useful? it would be a design thing but to keep it familiar you could have the “dots” down the bottom showing the number of pages.
    I have browsed around side scrolling sites and as you would expect they don’t “flick” to the next page and stop like the native OS …. if you know what i mean?

    Thanks again!!

  • http://iphonedevelopmentonwindows.com iphone Development On Windows Tom

    Thanks for the tips. They are very useful when you are first starting out. I knew about some of them already but I will have to implement some of the others straight away….thanks again.

  • http://www.squidoo.com/prosandconsofelectriccars Electric Car Ken

    This is a great starting point….I only wish that cross platform apps were easy to make….we could make a bundle….oh well…

  • kei

    nice writeup! i forwarded the link just now to my partner who’s an iphone dev. keep it up!

  • http://www.incirclemedia.com Incircle Media

    Really nice and healthy techniques/tips. we used couple of them and got more perfect application.

    Thanks to share for others.

    Cheers!

  • http://www.drm-removal-tool.com/ drm removal

    Beginners and intermediates will also appreciate:Hot CocoaThe podcasts are free through iTunes, and the host, Kevin Vinck, is an excellent instructor.

  • Martijn

    “2: “Hide” the Address Bar!”

    That doesn’t actually work…

    Who actually has this working, and on which device(s)?
    And where did you put the code? In the head? at the bottom? In DOMContentLoaded? In window.onload?

  • nicBBB

    Thanks for the tips. Just a question: when using an icon on the home screen and also setting the apple-mobile-web-app-capable parameter to “yes” and going in background, when resuming from the background application, the website is launched again from scratch. In other words, when the mobile web app goes in suspended mode, on resuming it doesn´t show the previous state. Is there a way to solve this?

  • http://www.removewmvdrm.com/ Remove WMV DRM

    thanks,that’s great

  • Runy

    Great tips,
    Has anyone used iwebkit to make a Ruby on Rails web app for the Iphone?
    I have a rails app online and want it to look like an iPhone app.

    Looking for a tutorial.