10 ms·
How to get that native iOS feel with PhoneGap
- nathanpc 14y agoAwesome tips. Congratulations for the awesome and informative article. :)
- tar 14y agoIf the original title begins with a number or number + gratuitous adjective, we'd appreciate it if you'd crop it. E.g. translate "10 Ways To Do X" to "How To Do X," and "14 Amazing Ys" to "Ys." Exception: when the number is meaningful, e.g. "The 5 Platonic Solids." http://ycombinator.com/newsguidelines.html http://ycombinator.com/newsguidelines.html
- mdellanoce 14y agoSorry about that. I will be sure to remember this.
- tszming 14y agoAre there any working examples using these tricks so we can test the difference? (The author's product request an invite to use)
- mdellanoce 14y agoUnfortunately, the app is still in review with Apple, so not at the moment. I also didn't realize this post would do so well with HN. I will work on a more in-depth follow-up with some working examples. Thanks so much for reading!
- tehwebguy 14y agoLooking forward to it, I already feel like you saved me 2 weeks in testing.
- joegaudet 14y agoI can speak from experience that using the 3d transform trick can make a real difference. We use them to emulate the Facebook / Path / Twitter swipe to move the main panel, performance isn't 100% of native - but it's pretty close.
- kerrishotts 14y agoThey make a /huge/ difference, especially if you stay within the tile size. In fact, using translate3d and CSS animation is pretty much the only way to get smooth animation - if you do it with pure JS (setting left/top styles), things get very herky-jerky.
- stungeye 14y agoI recommend checking out the Photoswipe source. It uses many of these techniques to create a swipe-based image gallery optimized for iOS and Android. https://github.com/codecomputerlove/PhotoSwipe https://github.com/codecomputerlove/PhotoSwipe Here's a simple HTML5/Photoswipe/Phonegap app I wrote that you could experiment with: https://github.com/stungeye/HTML5-Tumblr-Mobile-App https://github.com/stungeye/HTML5-Tumblr-Mobile-App Explained here: http://mobilehtml5.stungeye.com http://mobilehtml5.stungeye.com
- SG- 14y agoIt won't ever really 'feel' like a native app but it might look like one if you try real hard. My own experience and Facebook's too is that you just won't get the performance and you'll also be dealing with quirky CSS/HTML rendering. Edit: That's not to say that you can't make an app work, but you shouldn't try to make a typical app using mobile framework that tries to mimic a native app such as jquerymobile or others. If using a non-standard UI it can probably work where the user isn't expecting it to work and feel like a UITableView and every other basic thing in iOS.
- kerrishotts 14y agoI agree -- it is exceptionally difficult to create the look and feel just right in HTML5, CSS3, and JS. I swear that there's an "uncanny valley" for look and feel. To me it is better to bring over some of the "ios"-isms without duplicating the UI (and failing to get 100% right).
- briandear 14y agoWhy are people still using phone gap? What's the point? Might as well just build a web app. PhoneGap is the Dreamweaver of mobile.
- Dystopian 14y agoIsn't PhoneGap just the interpreter for an HTML5 web app - the wrapper to get it on the phone as an ipa? Unless it's changed a lot since 1.0 I don't believe it's some kind of WYSIWIG iPhone maker that creates bloated, terrible, code.
- Evbn 14y agoIt is called Apache Cordova now, and it is a set of implementations (one for each platform) providing JS hooks into native APIs, so they can be called from JS in a web view, so your web app runs in a native app container. Phone gap is now a set of technical/busisness services for managing Cordova projects, such as Build deployable packages for all platforms via a web service
- polshaw 14y agoBuild web app, package as smartphone app with phoneGap. Makes users happy.. right?
- alanning 14y agoMy current client is using PhoneGap to enable publishing to numerous device types without the need to hire developers for each platform. Particularly important due to their customers' global spread; supporting multiple platforms is a decided competitive advantage and finding devs is tough these days.
- kerrishotts 14y agoPhoneGap is getting better with every release, and it isn't too hard to make a nice, functional app. The promise of cross-platform holds only for so long - until either a plugin doesn't exist for the platform or a platform-specific glitch gets in the way, but overall it is a fun and rewarding thing to work with.
- 14y ago
- taterbase 14y agoMax Ogden also did a great write up on Web View optimizations. http://maxogden.com/fast-webview-applications http://maxogden.com/fast-webview-applications
- lukifer 14y agoGreat tips. For anyone who cares, here's a way to get around one of the fixed layout bugs with #6 (-webkit-overflow-scrolling: touch): http://blog.joelambert.co.uk/2011/10/14/a-fix-for-ios5-overflow-scrolling-scrollfix-js/ http://blog.joelambert.co.uk/2011/10/14/a-fix-for-ios5-overf...
- kerrishotts 14y agoOne thing I didn't notice, but is important in stoping overscroll is to se the UIWebViewBounce property in Cordova.plist to NO. This ensures you don't have to worry about things like ScrollFix which almost-but-not-quite-solves the same issue. Why Cordova defaults this to YES is beyond me.
- mdellanoce 14y agoGreat point, I wish I had remembered to add that!
- flyosity 14y agoNothing kills the illusion of an iPhone app feeling native faster than getting rid of overflow bouncing in a scrollable view. I understand there are performance benefits, but it feels so wrong on iOS.
- richardw 14y agoHow much does optimizing for iOS do anything bad for the app on, say, Android?
- mdellanoce 14y agoI can't really say, because we haven't done much testing on Android yet. My understanding is that Android's WebView uses a webkit rendering engine, but generally has poorer performance than the iOS UIWebView. So my guess is optimizing for iOS won't necessarily hurt anything for Android, but Android won't have quite as good of an experience. Hopefully this will get better with time... the UIWebView performance increase we saw from iOS 4 to iOS 5 is encouraging.
- mephju 14y agoSo much wasted effort to achieve something which a) doesn't really work well b) comes for free if you just go native. And your Android users will of course be super happy to find a bad iOS interface which is just slow. And once you are done imitating the iOS interface, the real work only begins ;)
- exogen 14y agoTrust me, these tips are still useful. My team is working with a company whose site is just shy of the top 100 in the US by traffic. Big company, been around for almost 100 years. What surprised us was that 50% of their traffic comes from mobile browsers. They even already have mobile apps for both iOS and Android, and still that much traffic goes to their mobile site. Also of interest: iPad users get the normal site. So 50% of their traffic is from phones. What do you serve to those people? Bug them to get the app anyway? On large sites involving several different divisions of a company, the native app probably only has 10% of the functionality. And serving the full "desktop" web experience might not be possible or desirable. While I think it can be a huge mistake to try to completely mimic a native app on the web, you can make the experience much better by at least adopting some mobile UI patterns. And in those cases, the tips on this list will save you. (Our work with this company involved adding stuff to both their "desktop" and mobile sites. We didn't use PhoneGap, but did use several of the tricks on this list.) As an aside, almost all of these tips have nothing to do with PhoneGap. They all apply just as well to any mobile site that's going to be using transitions to look like an app.
- jmitcheson 14y agoWhy do people hate on PhoneGap so much? Specifically, I mean when people complain that the UI of the apps produced with PhoneGap don't "feel" right. PhoneGap sacrifices the quality of the UI for benefits in other areas (a boost to development speed, and making it easier for a novice developer to get started). The argument against PhoneGap seems to be either that there isn't a place at all for such a technique, or that people think the benefits don't outweigh the drawbacks. Another option is that people dislike the developer accessibility aspect out of pure snobbery. However, I rarely hear people making these arguments. I just hear (not necessarily in this thread, but in previous ones) "blah blah it sucks blah blah why not write native code blah blah".
- veeti 14y ago> PhoneGap sacrifices the quality of the UI for benefits in other areas You said it yourself. PhoneGap is an easy way to get a sub-par user experience and that is what matters the most, not development speed.
- eli 14y agoThat is hardly a universal truth. I'd take ugly code that ships on time over beautiful code that doesn't.
- briandear 14y agoOk Mark Zuckerberg. Shipped code does not always beat unshipped code if the shipped code is shitty. In App Store contexts, badly shipped code can kill your app before it gains any traction leaving future updates moot. Anytime you deliver less than a beautiful UX you are doing a disservice to the user. The product can be simple and MVPish, but you should never ship shitty code. Zuckerberg doesn't know what he's talking about.
- briandear 14y agoThe UX is the absolute most important thing. Anything that sacrifices the user experience just to make it easier to develop is a bad tool. It's a tool for the lazy.
- b3b0p 14y agoWe use PhoneGap and thought it would fit well for us since our app is a touch based board game. We don't really use native widgets. It's all customized graphics for the game board and menu screen. I probably wouldn't use PhoneGap for an actual application that needed the native widgets look and feel, but for something like we are aiming for, I think it fits perfectly. We wanted to target as many platforms as possible.
- programminggeek 14y agoYou know a great way to get the native iOS look/feel? Use Kendo Mobile. It gives you native UI without all the bugginess of other frameworks like JQuery Mobile. Out of the box, using Kendo on iOS gives you a pretty native feeling app, esp. for things like form and image viewing type apps. Just know going in that PhoneGap has limitations and it is not going to be 100% perfect, but it's outstanding for hitting the first 80% to prove out an idea and get it on the app store. For an example of an app I wrote using Kendo Mobile, check out ReMeme on the app store. http://itunes.apple.com/us/app/rememe/id536802283?mt=8 http://itunes.apple.com/us/app/rememe/id536802283?mt=8
- Void_ 14y agoHiding elements by applying offscreen translation - how's the support on non-iOS devices?
- exogen 14y agoHaving just worked on a mobile site using this technique: it's fine. The one issue we found is that some older Android browsers support 2D translation but not 3D. We ended up using translate(x, 0) for the actual movement, but kept translate3d(0, 0, 0) around for the performance boost.