Profe De Informatica
Building iPhone Apps with HTML, CSS, and JavaScript
Jonathan Stark
Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo
Building iPhone Apps with HTML, CSS, and JavaScript
by Jonathan Stark
Copyright © 2010 Jonathan Stark. All rights reserved. Printed in the United States of America. Published by O’Reilly Media,Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Brian Jepson Production Editor: SumitaMukherji Copyeditor: Emily Quill Proofreader: Sada Preisch Printing History:
January 2010: First Edition.
Indexer: Fred Brown Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Building iPhone Apps with HTML, CSS, and JavaScript, theimage of a bluebird, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has beentaken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
TM
This book uses RepKover™, a durable and flexible lay-flat binding.
ISBN:978-0-596-80578-4 [M] 1262957633
To Erica—and that little jumping bean in her tummy.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Web AppsVersus Native Apps What Is a Web App? What Is a Native App? Pros and Cons Which Approach Is Right for You? Web Programming Crash Course Intro to HTML Intro to CSS Intro to JavaScript 1 1 1 2 2 3 3 6 9
2. Basic iPhone Styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
First Steps Preparing a Separate iPhone Stylesheet Controlling thePage Scaling Adding the iPhone CSS Adding the iPhone Look and Feel Adding Basic Behavior with jQuery What You’ve Learned 14 16 17 19 21 23 28
3. Advanced iPhone Styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Adding a Touch of Ajax Traffic Cop Simple Bells and Whistles Roll Your Own Back Button Adding an Icon to the Home Screen FullScreen Mode Changing the Status Bar Providing a Custom Startup Graphic 29 29 34 40 46 48 48 49
vii
What You’ve Learned
50
4. Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
With a Little Help from Our Friend Sliding Home Adding the Dates Panel Adding the Date Panel Adding the New Entry Panel Adding theSettings Panel Putting It All Together Customizing jQTouch What You’ve Learned 51 51 55 56 58 60 62 64 67
5. Client-Side Data Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
localStorage and sessionStorage Saving User Settings to localStorage Saving the Selected Date to sessionStorage Client-Side Database Creating a Database...
Regístrate para leer el documento completo.