内容简介
1 Going Mobile with iOS
So,you want to build an iOS app
'cause everyone wants one!
Apps live in an iTunes universe
Time to make a decision
It all starts with the iPhone SDK
Take alook around
Xcode includes app templates to help you get started
Xcode is a full-featured IDE
Xcode is the hub of your iOS project
Build your interface within Xcode
Add the button to your view
The iOS simulator lets you test your app on your Mac
iDecide's logic
Changing the button text
You're using the Model View Controller pattern
iDecide is actually a little simpler
What happened?
Use the GUI editor to connect UI controls to code
A component can trigger certain events
Connect your events to methods
You've built your first iPhone app!
Your iOS Toolbox
2 Hello,Renee!
First we need to figure out what Mike(really)wants
App design rules—the iOS HIG
HIG guidelines for pickers and buttons
Create a new View-based project for InstaEmail
The life of a root view
We need data
Use pickers when you want controlled input
Pickers get their data from a datasource
That pattern is back
First,declare that the controller conforms to both protocols
The datasource protocol has two required methods
Connect the datasource just like actions and outlets
There's just one method for the delegate protocol
Actions,outlets,and events
Connect the event to the action
Next,synthesize the property
Connect the picker to our outlet
Use your picker reference to pull the selected values
Your iOS Toolbox
3 Email needs variety
Renee is catching on
Make room for custom input
Header files describe the interface to your class
Auto-generated accessors also handle memory management
To keep your memory straight,you need to remember just two things
But when Mike's finished typing
Customize your UITextField
Components that use the keyboard ask it to appear
Ask the UITextField to give up focus
Messages in Objective-C use named arguments
Use message passing to tell our View Controller when the Done button is pressed
Where's the custom note?
Your Objective-C Toolbox
4 A table with a view
So,how do these views fit together?
The navigation template pulls multiple views together
The table view is built in
A table is a collection of cells
Just a few more drinks
Plists are an easy way to save and load data
Arrays(and more)have built-in support for plists
Use a detail view to drill down into data
A closer look at the detail view
Use the Navigation Controller to switch between views
Navigation Controllers maintain a stack of View Controllers
Dictionaries store information as key-value pairs
Debugging—the dark side of iOS development
First stop on your debugging adventure:the console
Interact with your application while it's running
Xcode supports you after your app breaks,too
The Xcode debugger shows you the state of your application
Your iOS Toolbox
5 Refining your app
It all started with Sam
Use the debugger to investigate the crash
Update your code to handle a plist of dictionaries
The Detail View needs data
The other keys are key
We have a usabilitv problem
Use a disclosure button to show there are more details available
Sales were going strong
Use Navigation Controller buttons to add drinks
The button should create a new view
We need a view&but not necessarily a new view
The View Controller defines the behavior for the view
A nib file contains the UI components and connections
You can subclass and extend View controllers like any other class
Modal views focus the user on the task at hand
Any view can present a modal view
Our modal view doesn't have a navigation bar
Create the Save and Cancel buttons
Write the Save and Cancel actions
Your iOS Toolbox
6 Everyone's an editor...
Sam is ready to add a Red-Headed School Girl
but the keyboard is in the way
Wrap your content in a scroll view
The scroll view is the same size as the screen
The keyboard changes the visible area
iOS notifies you about the keyboard
Register with the default notification center for events
Keyboard events tell you the keyboard state and size
The table view doesn't know its data has changed
The array is out of order,too
Table views have built-in support for editing and deleting
Your iOS Development Toolbox
Sam has another project in mind
7 We need more room
DrinkMixer on the iPad
The iPad simulator
The HIG covers iPads,too
Use Xcode to build your Universal app
Check your devices
Rotation is key with iPad
A persistent view problem
Don't forget the tableview
Your iOS Development Toolbox
8 Enterprise apps
HF bounty hunting
A new iPhone control
Choose a template to start iBountyHunter
There's a different structure for universal apps
Drawing how iBountyHunter iPhone works
and how it fits with the universal app
Build the fugitive list view
Next up:the Captured view
A view's contents are actually subviews
After a quick meeting with Bob
Core Data lets you focus on your app
Core Data needs to know what to load
Core Data describes entities with a Managed Object Model
Build your Fugitive entity
Use an NSFetchRequest to describe your search
Bob's database is a resource
Back to the Core Data stack
The template sets things up for a SQLite DB
iOS Apps are read-only
The iPhone's application structure defines where you can read and write
Copy the database to the Documents directory
Your Core Data Toolbox
9 Things are changing
Bob needs documentation
Everything stems from our object model
The data hasn't been updated
Data migration is a common problem
Migrate the old data into the new model
Xcode makes it easy to version your data model
Core Data can“lightly”migrate data
Here's what you've done so far
Bob has some design input
Your app has a lifecycle all its own
Multitasking rules of engagement
A quick demo with Bob
Use predicates for filtering data
We need to set a predicate on our NSFetchRequest
Core Data controller classes provide efficient results handling
Time for some high-efficiency streamlining
Create the new FetchedResultsController getter method
We need to refresh the data
Your Data Toolbox
10 Proof in the real world
For Bob,payment requires proof
The way to the camera
There's a method for checking
Prompt the user with action sheets
Bob needs the where,in addition to the when
Core Location can find you in a few ways
Add a new framework
Just latitude and longitude won't work for Bob
Map Kit comes with iOS
A little custom setup for the map
Annotations require a little more work
Fully implement the annotation protocol
Your Location Toolbox
11 Natural interfaces
Bob needs that iPad app,too
iOS HIG user experience guidelines
Iterate your interface,too
BountyHunterHD is based on a split-view controller
Unifying the custom stuff
It seems we have a problem
UIWebview has lots of options
HTML,CSS and Objective-C
Using UIWebView
Your NUI Toolbox
i The top 4 things(we didn't cover)
#1.Internationalization and Localization
Localizing string resources
#2.View animations
#3.Accelerometer
Understanding device acceleration
#4.A word or two about gaming
Quartz and OpenGL
ii Get ready for the App Store
Apple has rules
The Provisioning Profile pulls it all together
Keep track in the Organizer