Trova il tuo prossimo book preferito
Abbonati oggi e leggi gratis per 30 giorniInizia la tua prova gratuita di 30 giorniInformazioni sul libro
iPhone JavaScript Cookbook
Azioni libro
Inizia a leggere- Editore:
- Packt Publishing
- Pubblicato:
- Jun 23, 2011
- ISBN:
- 9781849691093
- Formato:
- Libro
Descrizione
Informazioni sul libro
iPhone JavaScript Cookbook
Descrizione
- Editore:
- Packt Publishing
- Pubblicato:
- Jun 23, 2011
- ISBN:
- 9781849691093
- Formato:
- Libro
Informazioni sull'autore
Correlati a iPhone JavaScript Cookbook
Anteprima del libro
iPhone JavaScript Cookbook - Arturo Fernandez Montoro
Table of Contents
iPhone JavaScript Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Frameworks Make Life Easier
Introduction
Installing the iUI framework
Getting ready
How to do it...
How it works...
There's more...
Installing the UiUIKit framework
Getting ready
How to do it...
How it works...
There's more...
Installing the XUI framework
Getting ready
How to do it...
How it works...
Installing the iWebKit framework
Getting ready
How to do it...
How it works...
There's more...
Installing the WebApp.Net framework
Getting ready
How to do it...
How it works...
There's more...
Installing the PhoneGap framework
Getting ready
How to do it...
How it works...
Installing the Sencha Touch framework
Getting ready
How to do it...
How it works...
Installing the Apple Dashcode framework
Getting ready
How to do it...
How it works...
2. Building Interfaces
Introduction
Creating a toolbar
Getting ready
How to do it...
How it works...
There's more...
See also
Modifying the default status bar
Getting ready
How to do it...
How it works...
See also
Creating a footer
Getting ready
How to do it...
How it works...
See also
Creating a back button
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a button for the toolbar
Getting ready
How to do it...
How it works...
See also
Building a breadcrumb menu
Getting ready
How to do it...
How it works...
See also
Building the duo navigation buttons
Getting ready
How to do it...
How it works...
There's more....
See also
Building the lists for items
Getting ready
How to do it...
How it works...
There's more...
See also
Building menus using lists
Getting ready
How to do it...
Using UiUIKit
Using iWebKit
How it works...
There's more....
See also
Creating the toggle buttons
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a modal box with buttons
Getting ready
How to do it...
How it works...
See also
Building a search dialog
Getting ready
How to do it...
How it works...
There's more...
See also
Building the information fields
Getting ready
How to do it...
How it works...
See also
Building forms with checkboxes, radio buttons, select fields, and text fields
Getting ready
How to do it...
How it works...
There's more...
See also
Creating and customizing a notification box
Getting ready
How to do it...
How it works...
There's more
See also
Building a chat-style interface
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a date picker
Getting ready
How to do it...
How it works...
See also
Using different tabs
Getting ready
How to do it...
How it works...
See also
3. Events and Actions
Introduction
Identifying the devices
Getting ready
How to do it...
How it works...
There's more...
See also
Viewing applications in full screen
How to do it...
How it works...
See also
Detecting full screen or browser mode
How to do it...
How it works...
See also
Scaling to device width
How to do it...
How it works...
See also
Preventing scaling
How to do it...
How it works...
See also
Detecting one-finger events
Getting ready
How to do it...
How it works...
There's more...
See also
Detecting multi-touch events
Getting ready
How to do it...
How it works...
There's more...
See also
Preventing the default behavior for events
How to do it...
How it works...
See also
Detecting rotation events
Getting ready
How to do it...
How it works...
See also
Implementing drag-and-drop
Getting ready
How to do it...
How it works...
There's more...
See also
Adding visual effects
Getting ready
How to do it...
How it works...
There's more...
See also
Running your web application without Internet access
Getting ready
How to do it...
How it works...
There's more...
See also
4. A Picture Speaks a Thousand Words
Introduction
Choosing an icon image for the application
Getting ready
How to do it...
How it works...
There's more...
See also
Specifying a splash image
Getting ready
How to do it...
How it works...
See also
Displaying an image inside a container
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a grid with images
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a carousel for images
Getting ready
How to do it...
How it works...
There's more...
See also
Rotating images
Getting ready
How to do it...
How it works...
There's more...
See also
Scaling an image by applying animations
Getting ready
How to do it...
How it works...
There's more...
See also
Taking and displaying pictures
Getting ready
How to do it...
How it works...
There's more...
See also
Drawing geometric figures
Getting ready
How to do it...
How it works...
There's more...
See also
Applying colors
Getting ready
How to do it...
How it works...
See also
Working with gradients
Getting ready
How to do it...
Applying linear gradients
Using radial gradients
How it works...
See also
Adding an activity indicator
Getting ready
How to do it...
How it works...
There's more...
See also
5. Mastering Sound and Music
Introduction
Making a beep alert
Getting ready
How to do it...
How it works...
There's more...
See also
Making a vibrate alert
Getting ready
How to do it...
How it works...
See also
Creating an iPod playlist and playing a specific item
Getting ready
How to do it...
How it works...
There's more...
See also
Loading an iTunes playlist
Getting ready
How to do it...
How it works...
See also
Playing an audio file
Getting ready
How to do it...
Using HTML5
Using Sencha Touch
Using PhoneGap
How it works...
HTML5 approach
Sencha Touch approach
PhoneGap approach
There's more...
See also
Playing a video
Getting ready
How to do it...
Using HTML5
Using Sencha Touch
How it works...
There's more...
See also
Recording an audio
Getting ready
How to do it...
How it works...
See also
6. Exchanging Data: AJAX
Introduction
How to send HTTP requests
Getting ready
How to do it...
How it works...
There's more...
See also
Processing JSON responses
Getting ready
How to do it...
How it works...
There's more...
See also
Sending cross-domain requests
Getting ready
How to do it...
How it works...
There's more...
See also
7. Working with Data: Storage and SQL
Introduction
Creating a database
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a table
Getting ready
How to do it...
How it works...
See also
Inserting records
Getting ready
How to do it...
How it works...
See also
Searching and selecting records
Getting ready
How to do it...
How it works...
See also
Deleting records
Getting ready
How to do it...
How it works...
See also
Saving and reading preferences
Getting ready
How to do it...
How it works...
See also
Storing data in session
Getting ready
How to do it...
How it works...
There's more...
See also
8. This is a Phone
Introduction
Calling a number
Getting ready
How to do it...
How it works...
See also
Sending an SMS to a number
Getting ready
How to do it...
How it works...
See also
Selecting contacts
Getting ready
How to do it...
How it works...
See also
Creating a new contact
Getting ready
How to do it...
How it works...
See also
Searching and displaying contacts
Getting ready
How to do it...
How it works...
See also
9. Location, Location, Location
Introduction
Detecting current orientation
Getting ready
How to do it...
How it works...
See also
Identifying the current location
Getting ready
How to do it...
How it works...
There's more...
See also
Opening Google Maps at a specific location
Getting ready
How to do it...
How it works...
There's more...
See also
Calculating distances between two points
Getting ready
How to do it...
How it works...
There's more...
See also
10. Web 2.0 Integration
Introduction
Embedding an RSS feed
Getting ready
How to do it...
How it works...
There's more...
See also
Opening a YouTube video
Getting ready
How to do it...
How it works...
See also
Posting on your Facebook wall
Getting ready
How to do it...
How it works...
There's more...
See also
Retrieving recent tweets from Twitter
Getting ready
How to do it...
How it works...
There's more...
See also
Displaying photos from Flickr
Getting ready
How to do it...
How it works...
See also
Index
iPhone JavaScript Cookbook
iPhone JavaScript Cookbook
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2011
Production Reference: 1170611
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-849691-08-6
www.packtpub.com
Cover Image by Duraid Fatouhi (<duraidfatouhi@yahoo.com>)
Credits
Author
Arturo Fernandez Montoro
Reviewers
Taylor Jasko
Thomas Schreiber
Acquisition Editor
Steven Wilding
Development Editor
Alina Lewis
Technical Editors
Joyslita D’Souza
Merwine Machado
Aditi Suvarna
Copy Editors
Neha Shetty
Laxmi Subramanian
Project Coordinator
Zainab Bagasrawala
Indexer
Monica Ajmera Mehta
Proofreader
Lynda Sliwoski
Graphics
Geetanjali Sawant
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade
About the Author
Arturo Fernandez Montoro is a web software engineer, developer, author, and technical writer specializing in Free and Open Source Software.
His professional experience includes technologies, such as Django, Rails, J2EE, PHP, XHTML, CSS, and JavaScript, and working as a software developer and architect, project manager, sysadmin, and consultant for different companies in Europe.
Since 2002, he often writes for different Linux and Open Source printed and online magazines, such as Todo Linux, Linux+, Linux Magazine, Free Software Magazine, and Rails Magazine.
Currently, Arturo works as a Python/Django developer, contributing to one of the most important and visited websites in Spain. He can be reached at <arturo@bsnux.com>.
Many thanks to my friends and colleagues Lui Palacios and Thomas Schreiber for contributing to this book with their advice and revisions.
My wife Alicia is a living proof of the power of love. Thank you for starting a family together.
This book would have never been possible without the help and work of the team at Packt Publishing. My sincere acknowledgements to Steven, Zainab, and Alina.
Special thanks to all people who contribute to Free and Open Source with their knowledge, effort, time, patience, and enthusiasm. We’re changing the world.
Thanks to my parents Jose and Aurora for teaching me to be the person I am today.
My brother Ernesto is someone who never gives up. Thank you for making my life enjoyable.
In memoriam of my grandmother Aurora, who passed away during the writing of this book.
About the Reviewers
Taylor Jasko, a student who is currently attending high school, has been fascinated with technology ever since the day he laid his hands on a Windows 95-based computer. Since then, now being eighteen years old, he has dived into web design and development, computer programming, and even system admin work with his favorite server-oriented operating system, Debian Linux.
He found the technology blog Tech Cores (http://techcores.com) and has been working on it ever since it was created back in late 2008. Tech Cores is a great example of his work; he designed and created it using the powerful WordPress content management system and with the help of his Wacom Intuos4 graphic tablet and Adobe Photoshop.
While in school, he can be found freelancing graphic designing and programming work. His technical strengths include PHP, JavaScript (including libraries like jQuery), AJAX, HTML, CSS, Perl, Objective C, Linux/UNIX, MySQL, Apache, Nginx, and to finish it all off, a dab of Python. Essentially, he’s a programmer, system admin, and a designer!
He can be reached at <taylor.jasko@gmail.com>.
Thomas Schreiber was born and raised in the United States and holds a Bachelor of Arts in Digital Media from Temple University’s Tyler School of Art. He is a Python web developer using Django, Pinax, and many other exciting technologies. He is also a techno musician who performed at and organized hundreds of events in Philadelphia spanning the last nine years. Thomas currently lives in Madrid with his wife Yulka, dog Finnegan, and is currently working as a lead web developer for Unidad Editorial on a social media platform. His detailed profile can be found at http://insatsu.us/collective/thomas-schreiber/.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read, and search across Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
Undoubtedly, iPhone is one of the most exciting mobile devices in the world. Its iOS is used in other Apple devices, such as iPad and iPod Touch. With this book, you'll learn how to build and develop applications for these devices without applying Apple's burdensome and, at times, restrictive technologies. Just use your experience and knowledge combined with web frontend technologies, such as JavaScript, to build quality web applications. Nobody will ever come to know that you haven't used Objective-C and Cocoa.
iPhone JavaScript Cookbook offers a set of practical and clear recipes with a step-by-step approach for building your own iPhone applications by only applying web technologies such as JavaScript and AJAX. Web developers won't need to learn a new programming language for building iOS applications with a native look and feel.
What this book covers
Chapter 1 , Frameworks Make Life Easier, is the getting started
chapter of this book. It covers how to install and set up different frameworks, which will be used for the recipes of the book.
Chapter 2 , Building Interfaces, introduces you to the world of iPhone applications. You'll learn how to build essential and advanced interfaces, such as buttons, lists, forms, and date pickers.
Chapter 3 , Events and Actions, discovers how to deal with events and actions. Both allow us a better control of the interaction between the user and the device.
Chapter 4 , A Picture Speaks a Thousand Words, takes advantage of the great screens of iPhone and iPad teaching you how to display a grid of images, how to apply different effects, and how to work with the built-in camera of the device.
Chapter 5 , Mastering Sound and Music, explores the audio and video capabilities of iPhone. You'll learn how to play and record audio and how to create iPod playlists.
Chapter 6 , Exchanging Data: AJAX, covers how to use this technology for exchanging data between the server and the client. Readers are walked through the process of sending HTTP requests and processing JSON responses.
Chapter 7 , Working with Data: Storage and SQL, provides coverage of the process for storing and retrieving data using the SQL language. Also, you'll learn how to deal with different kinds of storage available in iPhone.
Chapter 8 , This is a Phone, enlightens that we cannot forget that iPhone is a smartphone. This is the reason to get focused on learning how to create, select and display contacts, and how to call a number and send an SMS.
Chapter 9 , Location, Location, Location, introduces to readers to geolocation, showing how to detect the current orientation and position, and how to use the API provided by Google Maps for displaying a map at a specific location.
Chapter 10 , Web 2.0 Integration, helps readers learn how to integrate their iPhone applications with third-party popular services such as Facebook, YouTube, Twitter, and Flickr.
What you need for this book
If you're planning to build native applications, you'll need a computer with Mac OS X, iOS SDK, and Xcode installed.
Despite the fact that it's possible to use a WebKit-compatible web browser for the recipes of this book, we suggest to use a real Apple device, such as an iPhone and iPad. However, the iPhone Simulator is a very useful tool that you can use on your Mac for testing applications.
Who this book is for
This book is for web developers interested in applying their knowledge for building web applications for iOS devices. You can develop your own iPhone web applications using nothing but JavaScript combined with XHTML and CSS. You can even give these applications a native look and feel though you wont be able to submit them to the application store. You will develop an application for iOS without having to learn the Objective-C programming language. This is the book for any iPhone developer looking to side step the totalitarian application store regime of Apple.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: we'll need to add a span element for the smallfield label.
A block of code is set as follows:
Any command-line input or output is written as follows:
$ wget http://iui.googlecode.com/files/iui-0.31.tar.gz
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: After clicking on the Search button, we'll see our dialog box:
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be
Recensioni
Recensioni
Cosa pensano gli utenti di iPhone JavaScript Cookbook
00 valutazioni / 0 recensioni