Community »iOS Development Tutorials

iOS SDK Examples and Tutorials

Download our iOS developer examples.

Feel free to download any or all of the example code for the Xcode projects shown below to aid your learning. You can even incorporate the code in your own iPhone and iPad apps if you like.

The initial set of examples show how to configure the user interface programmatically—in other words, without using Interface Builder. In the coming weeks we'll be posting new versions of these examples that will show you how to configure the same user interfaces in Interface Builder. That way you'll be able to compare the programmatic and IB-based examples side-by-side to get a clearer picture of how Interface Builder interacts with your code.

Windows, Views, and Controls

A set of examples that introduces a few of the fundamentals of iPhone programming. A good place to start if you're relatively new to iPhone development.

 
image

First App

Puts a UIWindow with a nested UIView onscreen. If you're new to iPhone development, this is the place to start.

Demonstrates how to:

  • Set up a project that configures its user interface programatically.
  • Create a custom class that implements the UIApplicationDelegate protocol.
  • Configure the application's delegate in main.m.
  • Create an instance of UIWindow and display it on screen.
  • Add a subview to the app's main window.
Download First App Example

Posted: July 7, 2009

 
image

Editable Detail View

Provides a text field and button that allows you to interact with the user interface.

Demonstrates how to:

  • Use CGRect structures to size and position subviews.
  • Create instances of UIControl subclasses such as UITextField and UIButton and place them on the screen.
  • Implement action methods to handle user touches.
  • Access and modify the value of a UITextField in response to user-generated events..
  • Dynamically modify the value of a UILabel.
Download Editable Detail View Example

Posted: July 7, 2009

 
image

Animating a View

Provides a text field and button that allows you to interact with the user interface.

Demonstrates how to:

  • Create a custom subclass of UIView that provides custom animation behavior.
  • Begin and commit a CAAnimation block.
  • Add one or more CAAffineTransform structures to an instance of UIView.
  • Set animation attributes such as the animation curve, duration, and repeat count.
Download Animating A View Example

Posted: July 7, 2009

Updated: Sept 15, 2009

Table Views

A series of progressive examples that take you step-by-step through the development of a full-featured app that makes use of table views and navigation controllers.

 
image

Simple TableView

An app that contains a list-style UITableView that displays values derived from an array of strings. If your new to using UITableView, this is a great place to start.

Demonstrates how to:

  • Create a custom subclass of UITableViewController.
  • Implement the required methods of the UITableViewDataSource protocol to populate a UITableView.
  • Create and populate instances of UITableViewCell.
  • Display two different strings with differing font attributes in each row of a table view.
Download Simple TableView Example

Posted: July 7, 2009

Updated: Sept 15, 2009

 
image

TableView with Navigation

Contains a list-style UITableView that drills down to a grouped-style table view when the user taps on a row.

Demonstrates how to:

  • Use a UINavigationController to provide navigation between different screens by managing a stack of UIViewController instances.
  • Implement the tableViewDidSelectRowAtIndexPath: method of the UITableViewDelegate protocol to handle selection of a row by navigating to another view.
  • Manage the appearance of a UITableViewCell by configuring fonts and other settings.
  • Cause the data presented in a UITableView to be automatically reloaded as necessary
  • Use a grouped-style UITableView to present a detail view mapped to the properties of a model object.
Download TableView With Navigation Example

Posted: July 7, 2009

Updated: Sept 15, 2009

 
image

Editable TableView

Has an editable list-style UITableView that allows adding, removing, and reordering of rows, and that drills down to a grouped-style table view containing editable fields that allow editing of the properties of an underlying model object.

Demonstrates how to:

  • Create a custom subclass of UITableViewCell that adds a UITextField to its content view to make the cell's text editable.
  • Use a modal UINavigationController to add a new item to a UITableView.
  • Create and resize a UIImage with which to set a cell's image.
  • Manage a table view's keyboard, making it appear, changing the keyboard type, and dismissing it programatically.
  • Manage a the buttons in a navigation controller's UINavigationBar.
Download Editable TableView Example

Posted: July 7, 2009

Updated: Sept 15, 2009

 
image

TableView with File-Based Persistence

Similar to Editable TableView, but adds a number of features, including file-based persistence of the array of model objects that the app manages.

Demonstrates how to:

  • Create a custom subclass of UITableViewCell that adds a UITextField to its content view to make the cell's text editable.
  • Use a modal UINavigationController to add a new item to a UITableView.
  • Create and resize a UIImage with which to set a cell's image.
  • Manage a table view's keyboard, making it appear, changing the keyboard type, and dismissing it programatically.
  • Manage a the buttons in a navigation controller's UINavigationBar.
Download TableView With File Persistence Example

Posted: July 7, 2009

Updated: Jan 3, 2011