Beginning iPhone 4 Development Exploring the iOS SDK pptx

674 3.6K 0
Beginning iPhone 4 Development Exploring the iOS SDK pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

A comprehensive introduction to creating Apps for iPhone, iPad and iPod touch Beginning iPhone 4 Development Exploring the iOS SDK Dave Mark | Jack Nutting | Jeff LaMarche Covers iPad and iPod touch Mark Nutting LaMarche iPhone 4 Development Beginning Companion eBook Available Trim: 7.5 x 9.25 spine =1.28125" 680 page count 534ppi COMPANION eBOOK SEE LAST PAGE FOR DETAILS ON $10 eBOOK VERSION US $39.99 Shelve in Mobile Computing User level: Beginner–Intermediate www.apress.com http://iphonedevbook.com/forum/ SOURCE CODE ONLINE BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® ISBN 978-1-4302-3024-3 9 781430 230243 53999 this print for content only—size & color not accurate CYAN MAGENTA YELLOW BLACK PANTONE 123 C SPOT MATTE T he authors of the bestselling Beginning iPhone 3 Development are back, with more excellent material completely updated from the ground up for iOS 4 and the latest version of Apple¹s Xcode 3. All source code has been re- worked to use the latest Xcode templates and current APIs, with brand new screenshots showing iOS 4 and Xcode 3 in action. Beginning iPhone 4 Development is a complete course in iOS development. You’ll master techniques that work on iPhone, iPad, and iPod touch. We start with the basics, showing you how to download and install the tools you’ll need, and how to create your first simple application. Next you’ll learn to integrate all the inter- face elements iOS users have come to know and love, such as buttons, switches, pickers, toolbars, and sliders. You’ll master a variety of design patterns, from the simplest single view to complex hierarchical drill-downs. The confusing art of table building will be demystified, and you’ll learn techniques to save and re- trieve your data using SQLite, iPhone’s built-in database management system and Core Data, the standard for persistence that Apple brought to iOS with the release of SDK 3. And there’s much more! You’ll learn to draw using Quartz 2D and OpenGL ES, add multitouch gestural support (pinches and swipes) to your applications, and work with the camera, photo library, accelerometer, and built-in GPS. You’ll dis- cover the fine points of application preferences and learn how to localize your apps for multiple languages. You’ll also learn how to use the new concurren- cy APIs included in iOS 4, and make robust multithreaded applications using Grand Central Dispatch. • The iPhone 4 update to the best-selling and most recommended book for Cocoa Touch developers • Written in an accessible, easy-to-follow style • Full of useful tips and techniques to help you become an iOS pro 1 1 Chapter Welcome to the Jungle So, you want to write iPhone, iPod touch, and iPad applications? Well, we can’t say that we blame you. iOS, the core software of all of these devices, might just be the most interesting new platform to come around in a long time. Certainly, it is the most interesting mobile platform to date, especially now that Apple has provided a set of elegant, well-documented tools for developing iOS applications. And with the release of version 4 of the iOS software development kit (SDK), things have only gotten better. What This Book Is This book is a guide to help you get started down the path to creating your own iOS applications. Our goal is to get you past the initial learning curve to help you understand the way iOS applications work and how they are built. As you work your way through this book, you will create a number of small applications, each designed to highlight specific iOS features and show you how to control or interact with those features. If you combine the foundation you’ll gain by making your way through this book with your own creativity and determination, and then add in the extensive and well-written documentation provided by Apple, you’ll have everything you need to build your own professional iPhone and iPad applications. TIP: Dave, Jack, and Jeff have a forum set up for this book. It’s a great place to meet like- minded folks, get your questions answered, and even answer other people’s questions. It’s at http://iphonedevbook.com/forum. Be sure to check it out! What You Need Before you can begin writing software for iOS, you’ll need a few things. For starters, you’ll need an Intel-based Macintosh running Snow Leopard (OS X 10.6.5 or later). Any recent Intel-based Macintosh computer—laptop or desktop—should work just fine. 1 Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m > CHAPTER 1: Welcome to the Jungle 2 You’ll also need to sign up to become a registered iOS developer. Apple requires this step before you’re allowed to download the iOS SDK. To sign up, navigate to http://developer.apple.com/ios/, which will bring you to a page similar to the one shown in Figure 1–1. Figure 1–1. Apple’s iOS Dev Center web site CHAPTER 1: Welcome to the Jungle 3 First, click the button labeled Log in. You’ll be prompted for your Apple ID. If you don’t have an Apple ID, click the Create Apple ID button, create one, and then log in. Once you are logged in, you’ll be taken to the main iOS development page. Not only will you see a link to the SDK download, but you’ll also find links to a wealth of documentation, videos, sample code, and the like—all dedicated to teaching you the finer points of iOS application development. One of the most important downloads on this page is Xcode, Apple’s integrated development environment (IDE). Xcode includes tools for creating and debugging source code, compiling applications, and performance tuning the applications you’ve written. By the time you are finished with this book, you will become an Xcode aficionado! SDK VERSIONS AND SOURCE CODE FOR THE EXAMPLES As the versions of the SDK and Xcode evolve, the mechanism for downloading them will also change. Sometimes the SDK and Xcode are featured as separate downloads; other times, they will be merged as a single download. Bottom line: you want to download the latest released (nonbeta) version of the SDK and Xcode. This book has been written to work with the latest version of the SDK. In some places, we have chosen to use new functions or methods introduced with version 4 that may prove incompatible with earlier versions of the SDK. We’ll be sure to point those situations out as they arise in this book. Be sure to download the latest and greatest source code archives from the book’s web site at http://iphonedevbook.com. We’ll update the code as new versions of the SDK are released, so be sure to check the site periodically. Developer Options The free SDK download option includes a simulator that will allow you to build and run iPhone and iPad apps on your Mac. This is perfect for learning how to program for iOS. However, the simulator does not support hardware-dependent features, such as the iPhone’s accelerometer or camera. Also, the free option will not allow you to download your applications onto your actual iPhone or other device. And it does not give you the ability to distribute your applications on Apple’s App Store. For those capabilities, you’ll need to sign up for one of the other options, which aren’t free: The Standard program costs $99/year. It provides a host of development tools and resources, technical support, distribution of your application via Apple’s App Store, and, most important, the ability to test and debug your code on an iOS device, rather than just in the simulator. The Enterprise program costs $299/year. It is designed for companies developing proprietary, in-house iOS applications and for those developing applications for the Apple’s App Store, and with more than one developer working on the project. CHAPTER 1: Welcome to the Jungle 4 For more details on these programs, visit http://developer.apple.com/programs/ios and http://developer.apple.com/programs/ios/enterprise to compare the two. Because iOS supports an always-connected mobile device that uses other companies’ wireless infrastructure, Apple has needed to place far more restrictions on iOS developers than it ever has on Mac developers (who are able—at least as of this writing—to write and distribute programs with absolutely no oversight or approval from Apple). Even though the iPod touch and the Wi-Fi–only versions of the iPad don’t use anyone else’s infrastructure, they’re still subject to these same restrictions. Apple has not added restrictions to be mean, but rather as an attempt to minimize the chances of malicious or poorly written programs being distributed that could degrade performance on the shared network. Developing for iOS may seem like it presents a lot of hoops to jump through, but Apple has expended quite an effort to make the process as painless as possible. And also consider that $99 is still considerably less than buying, for example, Visual Studio, which is Microsoft’s software development IDE. This may seem obvious, but you’ll also need an iPhone, iPod touch, or iPad. While much of your code can be tested using the iOS simulator, not all programs can be. And even those that can run on the simulator really need to be thoroughly tested on an actual device before you ever consider releasing your application to the public. NOTE: If you are going to sign up for the Standard or Enterprise program, you should go do it right now. The approval process can take a while, and you’ll need that approval to be able to run your applications on an actual device. Don’t worry, though, because all the projects in the first several chapters and the majority of the applications in this book will run just fine on the iOS simulator. What You Need to Know This book assumes that you already have some programming knowledge. It assumes that you understand the fundamentals of object-oriented programming (you know what objects, loops, and variables are, for example). It also assumes you are familiar with the Objective-C programming language. Cocoa Touch, the part of the SDK that you will be using through most of this book, uses Objective-C 2.0. But don’t worry if you’re not familiar with the more recent additions to the Objective-C language. We highlight any of the 2.0 language features we take advantage of, and explain how they work and why we are using them. You should also be familiar with iOS itself, as a user. Just as you would with any platform for which you wanted to write an application, get to know the iPhone, iPad, or iPod touch’s nuances and quirks. Take the time to get familiar with the iOS interface and with the way Apple’s iPhone and/or iPad applications look and feel. CHAPTER 1: Welcome to the Jungle 5 NEW TO OBJECTIVE-C? If you have not programmed in Objective-C before, here are a few resources to help you get started: Check out Learn Objective-C on the Mac, an excellent and approachable introduction to Objective-C by Mac programming experts Mark Dalrymple and Scott Knaster (Apress, 2009): http://www.apress.com/book/view/9781430218159 See Apple’s introduction to the language, Learning Objective-C: A Primer: http://developer.apple.com/library/ios/#referencelibrary/ GettingStarted/Learning_Objective-C_A_Primer Take a look at The Objective-C Programming Language, a very detailed and extensive description of the language and a great reference guide: http://developer.apple.com/library/ios/#documentation/Cocoa/ Conceptual/ObjectiveC That last one is also available as a free download from iBooks on your iPhone, iPod touch, or iPad. Perfect for reading on the go! Apple has released several developer titles in this format, and we hope that more are on the way. Search for “apple developer publications” in iBooks to find them. What’s Different About Coding for iOS? If you have never used Cocoa or its predecessors NeXTSTEP and OpenStep, you may find Cocoa Touch, the application framework you’ll be using to write iOS applications, a little alien. It has some fundamental differences from other common application frameworks, such as those used when building .NET or Java applications. Don’t worry too much if you feel a little lost at first. Just keep plugging away at the exercises, and it will all start to fall into place after a while. If you have written programs using Cocoa or NeXTSTEP, a lot in the iOS SDK will be familiar to you. A great many classes are unchanged from the versions that are used to develop for Mac OS X. Even those that are different tend to follow the same basic principles and use design patterns similar to the ones in the previous version. However, several differences exist between Cocoa and Cocoa Touch. Regardless of your background, you need to keep in mind some key differences between iOS development and desktop application development. CHAPTER 1: Welcome to the Jungle 6 Only One Active Application On iOS, only one application can be active and displayed on the screen at any given time. Starting with iOS 4, applications can sometimes continue to run in the background after the user presses the home button, but even that is limited to particular usages and situations. When your application isn’t active or running in the background, it doesn’t receive any attention from the CPU whatsoever, which will wreak havoc with open network connections and the like. iOS 4 makes great strides forward in allowing background processing, but making your apps play nicely in this situation will require some effort on your part. Only One Window Desktop and laptop operating systems allow many running programs to coexist, each with the ability to create and control multiple windows. However, iOS gives your application just one “window” to work with. All of your application’s interaction with the user takes place inside this one window, and its size is fixed at the size of the screen. Limited Access Programs on a computer pretty much have access to everything the user who launched them does. However, iOS seriously restricts what your application can get to. You can read and write files only from the part of iOS’s file system that was created for your application. This area is called your application’s sandbox. Your sandbox is where your application will store documents, preferences, and every other kind of data it may need to store. Your application is also constrained in some other ways. You will not be able to access low-number network ports on iOS, for example, or do anything else that would typically require root or administrative access on a desktop computer. Limited Response Time Because of the way it is used, iOS needs to be snappy, and it expects the same of your application. When your program is launched, you need to get your application open, preferences and data loaded, and the main view shown on the screen as fast as possible—in no more than a few seconds. At any time when your program is running, it may have the rug pulled out from under it. If the user presses the home button, iOS goes home, and you must quickly save everything and quit. If you take longer than five seconds to save and give up control, your application process will be killed, regardless of whether you are finished saving. CHAPTER 1: Welcome to the Jungle 7 Note that in iOS 4, this situation is ameliorated somewhat by the existence of a new API that allows your app to ask for additional time to work when it’s about to go dark. Limited Screen Size The iPhone’s screen is really nice. When introduced, it was the highest-resolution screen available on a consumer device, by far. But the iPhone display just isn’t all that big, and as a result, you have a lot less room to work with than on modern computers. The screen is just 640 × 960 on the latest Retina display devices (iPhone 4, and fourth-generation iPod touch) and 320 × 480 pixels on older devices. And that 640 × 960 Retina display is crammed into the same old form factor, so you can’t count on fitting more controls or anything like that—they will all just be higher resolution than before. The iPad increases things a bit by offering a 1024 × 768 display, but even today, that’s not so terribly large. To give an interesting contrast, at the time of this writing, Apple’s least expensive iMac supports 1920 × 1080 pixels, and its least expensive notebook computer, the MacBook, supports 1280 × 800 pixels. On the other end of the spectrum, Apple’s largest current monitor, the 27-inch LED Cinema Display, offers a whopping 2560 × 1440 pixels. Limited System Resources Any old-time programmers who are reading this are likely laughing at the idea of a machine with at least 256MB of RAM and 8GB of storage being in any way resource- constrained, but it is true. Developing for iOS is not, perhaps, in exactly the same league as trying to write a complex spreadsheet application on a machine with 48KB of memory. But given the graphical nature of iOS and all the things it is capable of doing, running out of memory is very, very easy. The iOS devices available right now all have either 256MB or 512MB of physical RAM, though that will likely increase over time. Some of that memory is used for the screen buffer and by other system processes. Usually, no more than half of that memory is left for your application to use, and the amount can be considerably less. Although that may sound like it leaves a pretty decent amount of memory for such a small computer, there is another factor to consider when it comes to memory on iOS. Modern computer operating systems like Mac OS X will take chunks of memory that aren’t being used and write them out to disk in something called a swap file. The swap file allows applications to keep running, even when they have requested more memory than is actually available on the computer. iOS, however, will not write volatile memory, such as application data, out to a swap file. As a result, the amount of memory available to your application is constrained by the amount of unused physical memory in the iOS device. CHAPTER 1: Welcome to the Jungle 8 Cocoa Touch has built-in mechanisms for letting your application know that memory is getting low. When that happens, your application must free up unneeded memory or risk being forced to quit. No Garbage Collection We mentioned earlier that Cocoa Touch uses Objective-C 2.0, but one of the key new features of that language is not available with iOS: Cocoa Touch does not support garbage collection. Some New Stuff Since we’ve mentioned that Cocoa Touch is missing some features that Cocoa has, it seems only fair to mention that the iOS SDK contains some functionality that is not currently present in Cocoa or, at least, is not available on every Mac: The iOS SDK provides a way for your application to determine the iOS device’s current geographic coordinates using Core Location. Most iOS devices have built-in cameras and photo libraries, and the SDK provides mechanisms that allow your application to access both. iOS devices have a built-in accelerometer (and, in the latest iPhone and iPod touch, a gyroscope) that lets you detect how your device is being held and moved. A Different Approach Two things iOS devices don’t have are a physical keyboard and a mouse, which means you have a fundamentally different way of interacting with the user than you do when programming for a general-purpose computer. Fortunately, most of that interaction is handled for you. For example, if you add a text field to your application, iOS knows to bring up a keyboard when the user clicks in that field, without you needing to write any extra code. NOTE: Current devices do allow you to connect an external keyboard via Bluetooth, which gives you a nice keyboard experience and saves some screen real estate, but this is still a fairly rare usage. Connecting a mouse is still not an option at all. CHAPTER 1: Welcome to the Jungle 9 What’s in This Book Here is a very brief overview of the remaining chapters in this book: In Chapter 2, you’ll learn how to use Xcode’s partner in crime, Interface Builder, to create a simple interface, placing some text on the screen. In Chapter 3, you’ll start interacting with the user, building a simple application that dynamically updates displayed text at runtime based on buttons the user presses. Chapter 4 will build on Chapter 3 by introducing you to several more of iOS’s standard user interface controls. We’ll also look at how to use alerts and action sheets to prompt users to make a decision or to inform them that something out of the ordinary has occurred. In Chapter 5, we’ll look at handling autorotation and autosize attributes, the mechanisms that allow iOS applications to be used in both portrait and landscape modes. In Chapter 6, we’ll move into more advanced user interfaces and look at creating applications that support multiple views. We’ll show you how to change which view is being shown to the user at runtime, which will greatly enhance the potential of your apps. Tab bars and pickers are part of the standard iOS user interface. In Chapter 7, we’ll look at how to implement these interface elements. In Chapter 8, we’ll look at table views, the primary way of providing lists of data to the user and the foundation of hierarchical navigation- based applications. We’ll also see how to let the user search in your application data. One of the most common iOS application interfaces is the hierarchical list that lets you drill down to see more data or more details. In Chapter 9, you’ll learn what’s involved in implementing this standard type of interface. The iPad, with its different form factor from the other iOS devices, requires a different approach to displaying a GUI and provides some components to help make that happen. In Chapter 10, we’ll show you how to use the iPad-specific parts of the SDK. In Chapter 11, we’ll look at implementing application settings, which is iOS’s mechanism for letting users set their application-level preferences. [...]... we’ll explore the logical next steps for you to take on your journey to master the iOS SDK What’s New in This Update? Since the first edition of this book hit the bookstores, the growth of the iOS development community has been phenomenal The SDK has continually evolved, with Apple releasing a steady stream of SDK updates CHAPTER 1: Welcome to the Jungle Well, we’ve been busy, too! The second we found... have the terminology out of the way, take a look at the Groups & Files pane The first item in the list should bear the same name as your project, in this case, Hello World This item is the gathering point for the source code and the other resources specific to your project For the time being, don’t worry about the items in the Groups & Files pane except those under Hello World Take a look at Figure 2 4. .. particular app at the iPhone and its particular sized screen As of this writing, the iPhone and iPad are the only iOS devices supported by this template For now, we’ll stick with the iPhone No worries, we’ll get to the iPad later in the book To continue, click the Choose… button You’ll be asked to save your new project using the standard save sheet (see Figure 2–3) Type Hello World for the project name,... applications The icon labeled View-based Application is the simplest template and the one we’ll be using for the first several chapters The others provide additional code and/or resources needed to create common iOS application interfaces, as you’ll see in later chapters Click the View-based Application icon (as in Figure 2–2), and then select iPhone from the Product popup menu in the middle of the window... application including, among other things, the name of the icon file When you select Hello_World-Info.plist, the property list will appear in the editing pane (see Figure 2– 14) Within the property list, find a row with the label Icon file in the left column The corresponding right column in that same row should be empty Doubleclick the empty cell, and type in the name of the png file you just added to... like an authentic iOS application First, run your project When the simulator window appears, click the iPhone simulator’s home button, the black button with the white square at the very bottom of the window That will bring you back to the iPhone home screen (see Figure 2–11) Notice anything a bit, well, boring? Figure 2–11 Our Hello World application icon is just plain boring Take a look at the Hello... panes The pane that runs down the left side of the window is called the Groups & Files pane All of the resources that make up your project are grouped here, as are a number of relevant project settings Just as in the Finder, clicking the little triangle to the left of an item expands that item to show available subitems Click the triangle again to hide the subitems The top-right pane is called the Detail... of the windows, controls, and other elements that the user can see and interact with Controller: Binds the model and view together and is the application logic that decides how to handle the user’s inputs The goal in MVC is to make the objects that implement these three types of code as distinct from one another as possible Any object you create should be readily identifiable as belonging in one of the. .. expand the window to take up more of the screen There’s a lot of information crammed into this window, and it’s where you will be spending a lot of your iOS development time Figure 2 4 The Hello World project in Xcode 17 18 CHAPTER 2: Appeasing the Tiki Gods Your project window features a toolbar across the top, which gives you ready access to a lot of commonly used commands Below the toolbar, the window... and the iOS SDK installed on your machine You should also download the book projects archive from the book web site Here’s a link: http://www.iphonedevbook.com/forum/ The book forums are a great place to download the latest book source code, get your questions answered, and meet up with like-minded people Of course, you can also find the source code on the Apress web site: http://www.apress.com 13 14 . comprehensive introduction to creating Apps for iPhone, iPad and iPod touch Beginning iPhone 4 Development Exploring the iOS SDK Dave Mark | Jack Nutting | Jeff. journey to master the iOS SDK. What’s New in This Update? Since the first edition of this book hit the bookstores, the growth of the iOS development community

Ngày đăng: 06/03/2014, 07:20

Từ khóa liên quan

Mục lục

  • Contents at a Glance

  • Contents

  • About the Authors

  • About the Technical Reviewer

  • Acknowledgments

  • Preface

  • Welcome to the Jungle

    • What This Book Is

    • What You Need

      • Developer Options

      • What You Need to Know

    • What’s Different About Coding for iOS?

      • Only One Active Application

      • Only One Window

      • Limited Access

      • Limited Response Time

      • Limited Screen Size

      • Limited System Resources

      • No Garbage Collection

      • Some New Stuff

      • A Different Approach

    • What’s in This Book

    • What’s New in This Update?

    • Are You Ready?

  • Appeasing the Tiki Gods

    • Setting Up Your Project in Xcode

      • The Xcode Project Window

    • Introducing Interface Builder

      • What’s in the Nib File?

      • Adding a Label to the View

      • Changing Attributes

    • Some iPhone Polish—Finishing Touches

      • Ready to Compile and Run

    • Bring It on Home

  • Handling Basic Interaction

    • The Model-View-Controller Paradigm

    • Creating Our Project

    • Creating the View Controller

      • Outlets

      • Actions

      • Adding Actions and Outlets to the View Controller

      • Adding Actions and Outlets to the Implementation File

    • Using the Application Delegate

    • Editing MainWindow.xib

    • Editing Button_FunViewController.xib

      • Creating the View in Interface Builder

      • Connecting Everything

      • Trying It Out

    • Bring It on Home

  • More User Interface Fun

    • A Screen Full of Controls

    • Active, and Passive Controls

    • Creating the Application

    • Implementing the Image View and Text Fields

      • Determining Outlets

      • Determining Actions

      • Adding the Image View

      • Adding the Text Fields

      • Set the Attributes for the Second Text Field

      • Connecting Outlets

    • Closing the Keyboard

      • Closing the Keyboard When Done Is Tapped

      • Touching the Background to Close the Keyboard

    • Implementing the Slider and Label

      • Determining Outlets and Actions

      • Adding Outlets and Actions

      • Adding the Slider and Label

      • Connecting the Actions and Outlets

    • Implementing the Switches, Button, and Segmented Control

      • Adding Outlets and Actions

      • Adding the Switches, Button, and Segmented Control

      • Connecting the Switch Outlets and Actions

      • Adding the Button

    • Implementing the Action Sheet and Alert

      • Conforming to the Action Sheet Delegate Method

      • Showing the Action Sheet

      • Using the Action Sheet Delegate

    • Spiffing Up the Button

      • Using the viewDidLoad Method

      • Control States

      • Stretchable Images

    • Being a Good Memory Citizen

    • Crossing the Finish Line

  • Autorotation and Autosizing

    • The Mechanics of Autorotation

    • Handling Rotation Using Autosize Attributes

      • Specifying Rotation Support

      • Designing an Interface with Autosize Attributes

      • Using the Size Inspector’s Autosize Attributes

      • Setting the Buttons’ Autosize Attributes

    • Restructuring a View When Rotated

      • Declaring and Connecting Outlets

      • Moving the Buttons on Rotation

    • Swapping Views

      • Determining Outlets and Actions

      • Declaring Actions and Outlets

      • Designing the Two Views

      • Implementing the Swap and the Action

    • Rotating Out of Here

  • Multiview Applications

    • Common Types of Multiview Apps

    • The Architecture of a Multiview Application

      • The Root Controller

      • Anatomy of a Content View

    • Building View Switcher

      • Creating Our View Controller and Nib Files

      • Modifying the App Delegate

      • SwitchViewController.h

      • Adding a View Controller

      • Building a View with a Toolbar

      • Writing the Root View Controller

      • Implementing the Content Views

      • Animating the Transition

    • Switching Off

  • Tab Bars and Pickers

    • The Pickers Application

    • Delegates and Data Sources

    • Setting Up the Tab Bar Framework

      • Creating the Files

      • Adding the Root View Controller

      • Editing MainWindow.xib

      • Connect the Outlet, Then Run It

    • Implementing the Date Picker

    • Implementing the Single-Component Picker

      • Declaring Outlets and Actions

      • Building the View

      • Implementing the Controller as Data Source and Delegate

    • Implementing a Multicomponent Picker

      • Declaring Outlets and Actions

      • Building the View

      • Implementing the Controller

    • Implementing Dependent Components

    • Creating a Simple Game with a Custom Picker

      • Writing the Controller Header File

      • Building the View

      • Adding Image Resources

      • Implementing the Controller

      • Final Details

      • Linking in the Audio Toolbox Framework

    • Final Spin

  • Introduction to Table Views

    • Table View Basics

      • Table Views and Table View Cells

      • Grouped and Plain Tables

    • Implementing a Simple Table

      • Designing the View

      • Writing the Controller

      • Adding an Image

      • Using Table View Cell Styles

      • Setting the Indent Level

      • Handling Row Selection

      • Changing Font Size and Row Height

    • Customizing Table View Cells

      • Adding Subviews to the Table View Cell

      • Loading a UITableViewCell from a Nib

    • Grouped and Indexed Sections

      • Building the View

      • Importing the Data

      • Implementing the Controller

      • Adding an Index

    • Implementing a Search Bar

      • Rethinking the Design

      • A Deep Mutable Copy

      • Updating the Controller Header File

      • Modifying the View

      • Modifying the Controller Implementation

    • Putting It All on the Table

  • Navigation Controllers and Table Views

    • Navigation Controllers

      • Stacky Goodness

      • A Stack of Controllers

    • Nav, a Hierarchical Application in Six Parts

      • Meet the Subcontrollers

      • The Nav Application’s Skeleton

      • First Subcontroller: The Disclosure Button View

      • Second Subcontroller: The Checklist

      • Third Subcontroller: Controls on Table Rows

      • Fourth Subcontroller: Movable Rows

      • Fifth Subcontroller: Deletable Rows

      • Sixth Subcontroller: An Editable Detail Pane

      • But There’s One More Thing. . .

    • Breaking the Tape

  • iPad Considerations

    • Split Views and Popovers

      • Create a SplitView Project

      • The Xib Defines the Structure

      • The Code Defines the Functionality

    • Here Come the Presidents

      • Create Your Own Popover

    • iPad Wrap-Up

  • Application Settings and User Defaults

    • Getting to Know Your Settings Bundle

    • The AppSettings Application

      • Creating the Project

      • Working with the Settings Bundle

      • Reading Settings in Our Application

      • Changing Defaults from Our Application

      • Keeping It Real

    • Beam Me Up, Scotty

  • Basic Data Persistence

    • Your Application’s Sandbox

      • Getting the Documents Directory

      • Getting the tmp Directory

    • File-Saving Strategies

      • Single-File Persistence

      • Multiple-File Persistence

    • Using Property Lists

      • Property List Serialization

      • The First Version of the Persistence Application

    • Archiving Model Objects

      • Conforming to NSCoding

      • Implementing NSCopying

      • Archiving and Unarchiving Data Objects

      • The Archiving Application

    • Using iOS’s Embedded SQLite3

      • Creating or Opening the Database

      • Using Bind Variables

      • The SQLite3 Application

    • Using Core Data

      • Entities and Managed Objects

      • The Core Data Application

    • Persistence Rewarded

  • Grand Central Dispatch, Background Processing, and You

    • Grand Central Dispatch

    • Introducing SlowWorker

    • Threading Basics

    • Units of Work

    • GCD: Low-Level Queueing

      • Becoming a Blockhead

      • Improving SlowWorker

    • Background Processing

      • Application Life Cycle

      • State-Change Notifications

      • Creating State Lab

      • Exploring Execution States

      • Making Use of Execution State Changes

      • Handling the Inactive State

      • Handling the Background State

    • Grand Central Dispatch, Over and Out

  • Drawing with Quartz and OpenGL

    • Two Views of a Graphical World

    • The Quartz Approach to Drawing

      • Quartz 2D’s Graphics Contexts

      • The Coordinate System

      • Specifying Colors

      • Drawing Images in Context

      • Drawing Shapes: Polygons, Lines, and Curves

      • Quartz 2D Tool Sampler: Patterns, Gradients, and Dash Patterns

    • The QuartzFun Application

      • Setting Up the QuartzFun Application

      • Adding Quartz Drawing Code

      • Optimizing the QuartzFun Application

    • The GLFun Application

      • Setting Up the GLFun Application

      • Drawing with OpenGL

      • Finishing GLFun

    • Drawing to a Close

  • Taps, Touches, and Gestures

    • Multitouch Terminology

    • The Responder Chain

      • Up the Responder Chain

      • Forwarding an Event: Keeping the Responder Chain Alive

    • The Multitouch Architecture

      • Where to Put Touch Code

      • The Four Touch-Notification Methods

    • Detecting Touches

      • Building the TouchExplorer Application

      • Running TouchExplorer

    • Detecting Swipes

      • Building the Swipes Application

      • Using Automatic Gesture Recognition

      • Implementing Multiple Swipes

    • Detecting Multiple Taps

    • Detecting Pinches

    • Creating and Using Custom Gestures

      • Defining the Check Mark Gesture

      • Attaching the Check Mark Gesture to a View

    • Garçon? Check, Please!

  • Where Am I? Finding Your Way with Core Location

    • The Location Manager

      • Setting the Desired Accuracy

      • Setting the Distance Filter

      • Starting the Location Manager

      • Using the Location Manager Wisely

    • The Location Manager Delegate

      • Getting Location Updates

      • Getting Latitude and Longitude Using CLLocation

      • Error Notifications

    • Trying Out Core Location

      • Updating Location Manager

      • Determining Distance Traveled

    • Wherever You Go, There You Are

  • Whee! Gyro and Accelerometer!

    • Accelerometer Physics

    • Don’t Forget Rotation

    • Core Motion and the Motion Manager

      • Event-Based Motion

      • Proactive Motion Access

      • Accelerometer Results

    • Detecting Shakes

      • Baked-In Shaking

      • Shake and Break

    • Accelerometer As Directional Controller

      • Rolling Marbles

      • Writing the Ball View

      • Calculating Ball Movement

    • Rolling On

  • iPhone Camera and Photo Library

    • Using the Image Picker and UIImagePickerController

    • Implementing the Image Picker Controller Delegate

    • Road Testing the Camera and Library

      • Designing the Interface

      • Implementing the Camera View Controller

    • It’s a Snap!

  • Application Localization

    • Localization Architecture

    • Strings Files

      • What’s in a Strings File?

      • The Localized String Macro

    • Real-World iOS: Localizing Your Application

      • Setting Up LocalizeMe

      • Trying Out LocalizeMe

      • Localizing the Nib

      • Localizing an Image

      • Generating and Localizing a Strings File

      • Localizing the App Display Name

    • Auf Wiedersehen

  • Where to Next?

    • Getting Unstuck

      • Apple’s Documentation

      • Mailing Lists

      • Discussion Forums

      • Web Sites

      • Blogs

      • Conferences

      • Follow the Authors

    • Farewell

  • Index

    • Symbols & Numbers

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I, J

    • K

    • L

    • M

    • N

    • O

    • P

    • R

    • Q

    • S

    • T

    • U

    • V

    • W

    • Z

    • X, Y

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan