Beginning IOS 6 development

750 1.5K 0
Beginning IOS 6 development

Đ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

Beginning IOS 6 development

www.it-ebooks.info For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. www.it-ebooks.info v Contents at a Glance About the Authors �������������������������������������������������������������������������������������������������������������� xxi About the Technical Reviewers ��������������������������������������������������������������������������������������� xxiii Chapter 1: Welcome to the Jungle ■ �������������������������������������������������������������������������������������1 Chapter 2: Appeasing the Tiki Gods ■ ���������������������������������������������������������������������������������11 Chapter 3: Handling Basic Interaction ■ �����������������������������������������������������������������������������43 Chapter 4: More User Interface Fun ■ ��������������������������������������������������������������������������������69 Chapter 5: Autorotation and Autosizing ■ ������������������������������������������������������������������������115 Chapter 6: Multiview Applications ■ ��������������������������������������������������������������������������������139 Chapter 7: Tab Bars and Pickers ■ �����������������������������������������������������������������������������������169 Chapter 8: Introduction to Table Views ■ �������������������������������������������������������������������������221 Chapter 9: Navigation Controllers and Table Views ■ �������������������������������������������������������269 Chapter 10: Storyboards ■ ������������������������������������������������������������������������������������������������341 Chapter 11: iPad Considerations ■ �����������������������������������������������������������������������������������367 Chapter 12: Application Settings and User Defaults ■ ������������������������������������������������������397 Chapter 13: Basic Data Persistence ■ ������������������������������������������������������������������������������435 Chapter 14: Hey! You! Get onto iCloud! ■ �������������������������������������������������������������������������481 www.it-ebooks.info vi Contents at a Glance Chapter 15: Grand Central Dispatch, Background Processing, and You ■ ������������������������511 Chapter 16: Drawing with Quartz and OpenGL ■ ��������������������������������������������������������������545 Chapter 17: Taps, Touches, and Gestures ■ ����������������������������������������������������������������������585 Chapter 18: Where Am I? Finding Your Way with Core Location and Map Kit ■ ���������������619 Chapter 19: Whee! Gyro and Accelerometer! ■ ����������������������������������������������������������������637 Chapter 20: The Camera and Photo Library ■ �������������������������������������������������������������������667 Chapter 21: Collection View ■ ������������������������������������������������������������������������������������������677 Chapter 22: Application Localization ■ �����������������������������������������������������������������������������691 Appendix A: Where to Next? ■ ������������������������������������������������������������������������������������������717 Index ���������������������������������������������������������������������������������������������������������������������������������725 www.it-ebooks.info 1 Chapter 1 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, is an exciting platform that has been seeing explosive growth since it first came out in 2007. The rise of the mobile software platform means that people are using software everywhere they go. With the release of iOS 6, and the latest incarnation of the iOS software development kit (SDK), things have only gotten better and more interesting. 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 difficulties, 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 to show you how to control or interact with those features. If you combine the foundation you’ll gain 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, Jeff, and Fredrik have set up a forum for this book. It’s a great place to meet like-minded folks, get your questions answered, and even answer other people’s questions. The forum is at http://forum.learncocoa.org. Be sure to check it out! What You Need Before you can begin writing software for iOS, you’ll need a few items. For starters, you’ll need an Intel-based Macintosh, running Lion (OS X 10.7) or later. Any recent Intel-based Macintosh computer—laptop or desktop—should work just fine. www.it-ebooks.info 2 CHAPTER 1: Welcome to the Jungle 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 as a developer, just navigate to http://developer.apple.com/ios/. That will bring you to a page similar to the one shown in Figure 1-1. Figure 1-1. Apple’s iOS Dev Center website First, click on Log in. You’ll be prompted for your Apple ID. If you don’t have an Apple ID, click Join now, 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. The most important tool you’ll be using to develop iOS applications is called Xcode. Xcode is 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. You can download Xcode from the Mac App Store, which you can access from your Mac’s Apple menu. www.it-ebooks.info 3CHAPTER 1: Welcome to the Jungle As the versions of the SDK and Xcode evolve, the mechanism for downloading them will also change. Starting with the release of Xcode 4.3, Apple has been publishing the current “stable” version of Xcode and the iOS SDK on the Mac App Store, while simultaneously often providing developers the ability to download preview versions of upcoming releases from their developer site. Bottom line: you want to download the latest released (non-beta) version of Xcode and the iOS SDK, so use the Mac App Store. 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 iOS 6 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 http://iphonedevbook.com or from the book’s forum at http://forum.learncocoa.org. 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 many hardware-dependent features, such as the accelerometer and 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. 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 the moment anyway—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 appear to present 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 much less than buying, for example, Visual Studio, which is Microsoft’s software development IDE. SDK VERSIONS AND SOURCE CODE FOR THE EXAMPLES www.it-ebooks.info 4 CHAPTER 1: Welcome to the Jungle 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 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 that you are familiar with the Objective-C programming language. Cocoa Touch, the part of the SDK that you will be working with through most of this book, uses the latest version of Objective-C, which contains several new features not present in earlier versions. But don’t worry if you’re not familiar with the more recent additions to the Objective-C language. We highlight any of the new 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 nuances and quirks of the iPhone, iPad, or iPod touch. Take the time to get familiar with the iOS interface and with the way Apple’s iPhone and/or iPad applications look and feel. 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: For OS X and iOS (2nd edition, Apress, 2012):, an excellent and approachable introduction to Objective-C by Mac-programming experts Scott Knaster, Waqar Malik, and Mark Dalrymple: http://www.apress.com/book/view/9781430241881. See Apple’s introduction to the language, 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. The last two are available from http://developer.apple.com/library/ios/navigation/. That last one is also available as a free download from iBooks on your iPhone, iPod touch, or iPad. It’s 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. www.it-ebooks.info 5CHAPTER 1: Welcome to the Jungle What’s Different About Coding for iOS? If you have never programmed in Cocoa or its predecessors NeXTSTEP or 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 OS X. Even those that are different tend to follow the same basic principles and similar design patterns. 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. These differences are discussed in the following sections. Only One Active Application On iOS, only one application can be active and displayed on the screen at any given time. Since iOS 4, applications have been able to run in the background after the user presses the “home” button, but even that is limited to a narrow set of situations, and you must code for it specifically. When your application isn’t active or running in the background, it doesn’t receive any attention whatsoever from the CPU, which will wreak havoc with open network connections and the like. iOS allows 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 access. 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 retain. 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. www.it-ebooks.info 6 CHAPTER 1: Welcome to the Jungle 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. Note that since iOS 5, this situation has been ameliorated somewhat by the existence of 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 320 × 480 on the first few iPhone generations, and was later doubled in both directions to 640 × 960 with the introduction of the iPhone 4’s retina display. This was recently increased further to 640 × 1136 on the iPhone 5. That sounds like a decent number of pixels, but keep in minde that these retina displays are crammed into pretty small form factors, so you can’t count on fitting more controls or anything like that. This has a big impact on the kinds of applications and interactivity you can offer on an iPhone. The iPad increases the available space 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 writing, Apple’s least expensive iMac supports 1920 × 1080 pixels, and its least expensive notebook computer, the 11-inch MacBook Air, supports 1366 × 768 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. Note that the 3 rd generation iPad released in the spring of 2012 (which Apple confusingly calls the “new iPad” instead of incrementing the number from the previous iPad 2) actually doubles the screen resolution in both directions. But as with the retina iPhones, that 2048 × 1536 screen is in the same physical space as the old screen was, so you can’t really count on using those pixels the same way you would on a traditional screen. Limited System Resources Any old-time programmers who are reading this are likely laughing at the idea of a machine with at least 512MB of RAM and 16GB 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 it is capable of doing, running out of memory is very easy. The iOS devices available right now have either 512MB (iPhone 4, iPhone 4S, iPad 2), or 1024MB of physical RAM (iPhone 5, new iPad), 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 www.it-ebooks.info [...]... 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... 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 Well, we’ve been busy, too! The second we found out about iOS SDK 6, we immediately went to work, updating every... substantive changes as well, including a brand-new chapter on the new collection view that Apple added to iOS 6 And, of course, we reshot every screen shown in the book Are You Ready? iOS is an incredible computing platform and an exciting new frontier for your development pleasure Programming for iOS is going to be a new experience—different from working on any other platform For everything that looks... iOS and Mac OS X Since we’re building an iOS application, select Application in the iOS section to reveal the iOS application templates Figure 2-2.  The project template selection sheet lets you select from various templates when creating a new project Each of the icons shown in the upper-right pane in Figure 2-2 represents a separate project template that can be used as a starting point for your iOS. .. pictures, both of which are available to your application, if you ask nicely! In Chapter 20, we’ll show you how to ask nicely  From the beginning, all sorts of iOS applications have made use of table views to display dynamic, vertically scrolling lists of components In iOS 6, Apple has introduced a new class called UICollectionView which takes this concept a few steps further, giving developers lots of... create a small iOS application that will display the text “Hello, World!” We’ll look at what’s involved in creating an iOS application project in Xcode, work through the specifics of using Xcode’s Interface Builder to design our application’s user interface, and then run our application on the iOS simulator After that, we’ll give our application an icon to make it feel more like a real iOS application... device for development For now, click the Ignore button Alternatively, the Organizer window, which shows (among other things) the devices that have been synchronized with your computer, might appear In that case, just close the Organizer window If you choose to join the paid iOS Developer Program, you will gain access to a program portal that will tell you how to use your iOS device for development. .. application settings, which is iOS s mechanism for letting users set their application-level preferences  Chapter 13 covers data management on iOS We’ll talk about creating objects to hold application data and see how that data can be persisted to iOS s file system We’ll also discuss the basics of using Core Data, which allows you to save and retrieve data easily  In iOS 5 Apple introduced iCloud,... www.it-ebooks.info CHAPTER 1: Welcome to the Jungle  iOS developers have traditionally built user interfaces for their apps using nib files This is still a fully supported development style, but nowadays you can do even more with your designs using storyboards Chapter 10 covers this great new feature  The iPad, with its different form factor from the other iOS devices, requires a different approach to displaying... Your Project in Xcode By now, you should have Xcode and the iOS SDK installed on your machine You should also download the book project archive from the iPhone Dev Book web site (http://www.iphonedevbook.com/) While you’re at it, take a look at the book forums at http://forum.learncocoa.org/ The book forums are a great place to discuss iOS development, get your questions answered, and meet up with like-minded . software everywhere they go. With the release of iOS 6, and the latest incarnation of the iOS software development kit (SDK), things have only gotten better. points of iOS application development. The most important tool you’ll be using to develop iOS applications is called Xcode. Xcode is Apple’s integrated development

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

Từ khóa liên quan

Mục lục

  • Beginning iOS6 Development

    • Contents at a Glance

    • Contents

    • About the Authors

    • About the Technical Reviewers

    • Chapter 1: 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, but…

        • Some New Stuff

        • A Different Approach

      • What’s in This Book

      • What’s New in This Update?

      • Are You Ready?

    • Chapter 2: Appeasing the Tiki Gods

      • Setting Up Your Project in Xcode

        • The Xcode Workspace Window

          • The Toolbar

          • The Navigator View

          • The Jump Bar

          • The Utility Pane

          • Interface Builder

          • New Compiler and Debugger

        • A Closer Look at Our Project

      • Introducing Xcode’s Interface Builder

        • What’s in the Nib File?

        • The Library

        • Adding a Label to the View

        • Changing Attributes

      • Some iPhone Polish—Finishing Touches

      • Bring It on Home

    • Chapter 3: Handling Basic Interaction

      • The Model-View-Controller Paradigm

      • Creating Our Project

      • Looking at the View Controller

        • Understanding Outlets and Actions

          • Outlets

          • Actions

        • Cleaning Up the View Controller

        • Designing the User Interface

          • Adding the Buttons and Action Method

          • Adding the Label and Outlet

          • Writing the Action Method

        • Trying It Out

        • Adding some style

      • Looking at the Application Delegate

      • Bring It on Home

    • Chapter 4: More User Interface Fun

      • A Screen Full of Controls

      • Active, Static, and Passive Controls

      • Creating the Application

      • Implementing the Image View and Text Fields

        • Adding the Image View

        • Resizing the Image View

        • Setting View Attributes

          • The Mode Attribute

          • Tag

          • Interaction Checkboxes

          • The Alpha Value

          • Background

          • Drawing Checkboxes

          • Stretching

        • Adding the Text Fields

          • Text Field Inspector Settings

          • Setting the Attributes for the Second Text Field

        • Creating and Connecting Outlets

      • Closing the Keyboard

        • Closing the Keyboard When Done Is Tapped

        • Touching the Background to Close the Keyboard

        • Adding the Slider and Label

        • Adding Top Constraints

        • Creating and Connecting the Actions and Outlets

        • Implementing the Action Method

      • Implementing the Switches, Button, and Segmented Control

        • Sec27

          • Adding Two Labeled Switches

          • Connecting and Creating Outlets and Actions

        • Implementing the Switch Actions

          • Adding the Button

          • Connecting and Creating the Button Outlets and Actions

      • Implementing the Segmented Control Action

      • Implementing the Action Sheet and Alert

        • Conforming to the Action Sheet Delegate Method

        • Showing the Action Sheet

      • Spiffing Up the Button

        • Using the viewDidLoad Method

        • Control States

        • Stretchable Images

      • Crossing the Finish Line

    • Chapter 5: Autorotation and Autosizing

      • The Mechanics of Autorotation

        • Points, Pixels, and the Retina Display

        • Autorotation Approaches

      • Choosing Your View Orientations

        • Supported Orientations at the App Level

        • Per-Controller rotation support

      • Designing an Interface Using Constraints

        • Overriding Default Constraints

        • Full-Width Buttons

      • Restructuring a View When Rotated

        • Creating and Connecting Outlets

        • Moving the Buttons on Rotation

      • Swapping Views

        • Designing the Two Views

        • Implementing the Swap

        • Changing Outlet Collections

      • Rotating Out of Here

    • Chapter 6: Multiview Applications

      • Common Types of Multiview Apps

      • The Architecture of a Multiview Application

        • The Root Controller

        • Anatomy of a Content View

      • UINavigationController

        • Creating Our View Controller and Nib Files

        • Modifying the App Delegate

        • Modifying BIDSwitchViewController.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

    • Chapter 7: 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

        • Creating TabBarController.xib

        • The Initial Test Run

      • Implementing the Date Picker

      • Implementing the Single-Component Picker

        • Declaring Outlets and Actions

        • Building the View

        • Implementing the Controller as a 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

          • The spin Method

          • The viewDidLoad Method

        • Final Details

        • Linking in the Audio Toolbox Framework

      • Final Spin

    • Chapter 8: 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 the Font Size and Row Height

      • Customizing Table View Cells

        • Adding Subviews to the Table View Cell

        • Creating a UITableViewCell Subclass

          • Adding New Cells

          • Implementing the Controller’s Code

        • Loading a UITableViewCell from a Nib

          • Designing the Table View Cell in Interface Builder

          • Using the New Table View Cell

      • Grouped and Indexed Sections

        • Building the View

        • Importing the Data

        • Implementing the Controller

        • Adding an Index

      • Implementing a Search Bar

        • Adding a Navigation Bar

      • Putting It All on the Table

    • Chapter 9: Navigation Controllers and Table Views

      • Navigation Controller Basics

        • Stacky Goodness

        • A Stack of Controllers

      • Nav, a Hierarchical Application in Six Parts

        • Meet the Subcontrollers

          • The Disclosure Button View

          • The Checklist View

          • The Rows Control View

          • The Movable Rows View

          • The Deletable Rows View

          • The Editable Detail View

        • The Nav Application’s Skeleton

          • Creating the Top–Level View Controller

          • Setting Up the Navigation Controller

        • Adding the Images to the Project

        • First Subcontroller: The Disclosure Button View

          • Creating the Detail View

          • Modifying the Disclosure Button Controller

          • Adding a Disclosure Button Controller Instance

        • Second Subcontroller: The Checklist

          • Creating the Checklist View

          • Adding a Checklist Controller Instance

        • Third Subcontroller: Controls on Table Rows

          • Creating the Row Controls View

          • Adding a Rows Control Controller Instance

        • Fourth Subcontroller: Movable Rows

          • Creating the Movable Row View

          • Adding a Move Me Controller Instance

        • Fifth Subcontroller: Deletable Rows

          • Creating the Deletable Rows View

          • Adding a Delete Me Controller Instance

        • Sixth Subcontroller: An Editable Detail Pane

          • Creating the Data Model Object

          • Creating the Detail View Controller

          • Implementing the Detail View List Controller

          • Adding an Editable Detail View Controller Instance

        • But There’s One More Thing. . .

      • Breaking the Tape

    • Chapter 10: Storyboards

      • Creating a Simple Storyboard

      • Dynamic Prototype Cells

        • Dynamic Table Content, Storyboard-Style

        • Editing Prototype Cells

        • Good Old Table View Data Source

        • Will It Load?

      • Static Cells

        • Going Static

        • So Long, Good Old Table View Data Source

      • You Say Segue, I Say Segue

        • Creating Segue Navigator

        • Filling the Blank Slate

        • First Transition

        • A Slightly More Useful Task List

        • Viewing Task Details

        • Make More Segues, Please

        • Passing a Task from the List

        • Handling Task Details

        • Passing Back Details

        • Making the List Receive the Details

        • If Only We Could End with a Smooth Transition

    • Chapter 11: iPad Considerations

      • Split Views and Popovers

        • Creating a SplitView Project

        • The Storyboard Defines the Structure

        • The Code Defines the Functionality

          • The App Delegate

          • The Master View Controller

          • The Detail View Controller

      • Here Come the Presidents

      • Creating Your Own Popover

      • iPad Wrap-Up

    • Chapter 12: Application Settings and User Defaults

      • Getting to Know Your Settings Bundle

      • The AppSettings Application

        • Creating the Project

        • Working With the Settings Bundle

          • Adding a Settings Bundle to Our Project

          • Setting Up the Property List

          • Adding a Text Field Setting

          • Adding an Application Icon

          • Adding a Secure Text Field Setting

          • Adding a Multivalue Field

          • Adding a Toggle Switch Setting

          • Adding the Slider Setting

          • Adding Icons to the Settings Bundle

          • Adding a Child Settings View

        • Reading Settings in Our Application

          • Retrieving User Settings

          • Creating the Main View

          • Updating the Main View Controller

        • Changing Defaults from Our Application

        • Registering Default Values

        • Keeping It Real

      • Beam Me Up, Scotty

    • Chapter 13: 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

          • Creating the Persistence Project

          • Designing the Persistence Application View

          • Editing the Persistence Classes

      • Archiving Model Objects

        • Conforming to NSCoding

        • Implementing NSCopying

        • Archiving and Unarchiving Data Objects

        • The Archiving Application

          • Implementing the BIDFourLines Class

          • Implementing the BIDViewController Class

      • Using iOS’s Embedded SQLite3

        • Creating or Opening the Database

        • Using Bind Variables

        • The SQLite3 Application

          • Linking to the SQLite3 Library

          • Modifying the Persistence View Controller

      • Using Core Data

        • Entities and Managed Objects

          • Key-Value Coding

          • Putting It All in Context

          • Creating New Managed Objects

          • Retrieving Managed Objects

        • The Core Data Application

          • Designing the Data Model

          • Creating the Persistence View and Controller

          • Making the Persistence View Controller the Application’s Root Controller

      • Persistence Rewarded

    • Chapter 14: Hey! You! Get onto iCloud !

      • Managing Document Storage With UIDocument

        • Building TinyPix

        • Creating BIDTinyPixDocument

        • Code Master

        • Initial Storyboarding

        • Creating BIDTinyPixView

        • Storyboard Detailing

      • Adding iCloud Support

        • Creating a Provisioning Profile

        • Enabling iCloud Entitlements

        • How to Query

        • Save Where?

        • Storing Preferences on iCloud

      • What We Didn’t Cover

    • Chapter 15: 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

          • Don’t Forget That Main Thread

          • Giving Some Feedback

          • Concurrent Blocks

      • Background Processing

        • Application Life Cycle

        • State-Change Notifications

        • Creating State Lab

        • Exploring Execution States

        • Making Use of Execution State Changes

          • Active ➤ Inactive

          • Inactive ➤ Background

          • Background ➤ Inactive

          • Inactive ➤ Active

        • Handling the Inactive State

        • Handling the Background State

          • Removing Resources When Entering the Background

          • Saving State When Entering the Background

          • Requesting More Backgrounding Time

      • Grand Central Dispatch, Over and Out

    • Chapter 16: Drawing with Quartz and OpenGL

      • Two Views of a Graphical World

      • The Quartz 2D Approach to Drawing

        • Quartz 2D’s Graphics Contexts

        • The Coordinate System

        • Specifying Colors

          • A Bit of Color Theory for Your iOS Device’s Display

          • Other Color Models

          • Color Convenience Methods

        • 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

          • Creating a Random Color

          • Defining Application Constants

          • Implementing the QuartzFunView Skeleton

          • Creating and Connecting Outlets and Actions

          • Implementing the Action Methods

        • Adding Quartz 2D Drawing Code

          • Drawing the Line

          • Drawing the Rectangle and Ellipse

          • Drawing the Image

        • Optimizing the QuartzFun Application

      • The GLFun Application

        • Setting Up the GLFun Application

        • Creating BIDGLFunView

        • Updating BIDViewController

        • Updating the Nib

        • Finishing GLFun

      • Drawing to a Close

    • Chapter 17: Taps, Touches, and Gestures

      • Multitouch Terminology

      • The Responder Chain

        • Responding to Events

        • Forwarding an Event: Keeping the Responder Chain Alive

      • The Multitouch Architecture

      • The Four Touch Notification Methods

      • The TouchExplorer Application

      • The Swipes Application

        • Automatic Gesture Recognition

        • Implementing Multiple Swipes

      • Detecting Multiple Taps

      • Detecting Pinch and Rotation

      • Defining Custom Gestures

        • The CheckPlease Application

        • The CheckPlease Touch Methods

      • Garçon? Check, Please!

    • Chapter 18: Where Am I? Finding Your Way with Core Location and Map Kit

      • 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

      • Visualizing your movement on a map

      • Wherever You Go, There You Are

    • Chapter 19: 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

    • Chapter 20: The 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!

    • Chapter 21: Collection View

      • Creating the DialogViewer Project

      • Fixing the View Controller’s Class

      • Defining Custom Cells

      • Configuring the View Controller

      • Providing Content Cells

      • Making the Layout Flow

      • Providing Header Views

    • Chapter 22: 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

        • Base Internationalization

        • Localizing the App Display Name

      • Auf Wiedersehen

    • Appendix

      • Where to Next?

      • Apple’s Documentation

      • Mailing Lists

      • Discussion Forums

      • Web Sites

      • Blogs

      • Conferences

      • Follow the Authors

      • Farewell

    • Index

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

Tài liệu liên quan