User Interface Objects From Beginning iPhone 4 Development and The iPhone Developer’s Cookbook...

Preview:

Citation preview

User Interface ObjectsFrom Beginning iPhone 4 Development and The iPhone

Developer’s Cookbook (Chapter 4)

User Interface Elements

Views—visuals, provide canvas, and other interface visual objects.

ViewControllers –provides a way for user to interact with your application. Can send an action (method) to a target (object) when an event (touch or tap) occurs.

Visual Classes

Parent class –UIView ClassAlmost all interface objects

are children of UIView classUIWindow—specialized

container and home for all the views Set screen size Only see one at a time

May have many views within a single window

Visual Quickstart Guide iPhone SDK 3, pg 100

Views that Display Data

UITextView Text box that may be used for

display or user input Limited to single font and font

size

UILabel Read-only text, limited size

UIImageViews Show pictures. Load with UIImage objects May load a sequence of images

rather than single image

Views that Display Data, cont…

UIWebView Display web content (HTML, PDF, etc) May use to present stylized text Support zoom and scroll

MKMapViews Enables maps into application Allow map annotation (MKannotationView

and MKPinAnnotionView)

UIScrollView Display larger than normal content Adds horizontal and/or vertical scrolling Supports zoom

Views for Making Choices

UIAlertViewPop-up windowsMay customize message and buttonsUse when have two to three choices

UIActionSheetMenus that scroll up from bottom of screenServe same function as Alert view.Use when have 4 or more choices

Inputs and Values

UIButtonDisplays a buttonTriggers an event/actionListed as Round Rect

Buttons

UISegmentedControlDisplays a row of equally

sized buttonsBehave as radio buttons

UISwitchOn-off switch display

cont…

UISliderSlider along a horizontal

barSet value for the bar

UIPageControlLets user move between

pages

UITextFieldsOffer single line of text

input

Tables and Pickers

UITableViewScrolling list of choicesOffer rows of information

UIPickerSelect choices by scrolling

individual wheelsUIDatePicker is specialized

picker for dates

Bars

Compact views that extend from one side of screen to the other

Read the Human Interface Guidelines for limits on bar use before you add a specific bar.

UINavigationBar Used for navigation

UITabBar and UISearchBar

UIToolBar Provide a set of actions that act

on current view

Progress and Activity

UIActivityIndicatorViewSpinning wheel while task

is ongoingDoes not state when task

will end

UIProgressViewOffers bar that fills from

left to right

UIView and UIViewControllers

UIView has a visual representation

UIViewControllers have NO visual representationManage viewsLinking views to codeHandle reorientation eventsHandle navigation issues such as switching between

views

UIViewControllers

May be very general to very specific

Introduce functionality without additional programming

Limit or hide direct access to core featuresExample—camera access

Must use UIImagePickerController to snap a photo. Class pre-built GUI and will handle the taking of the photo and saving. After image is saved then pass control back to your application. No direct access to the camera or raw image data.

UIViewController

Parent class of view controllers

Handle reorientation tasks

Set how views look and which subviews are displayed

Handle reaction to views being displayed or dismissed

Handle view changes

UINavigationController

Allow navigate up and down hierarchies

Create navigation bars

Handles push new views and generate back buttons

Handles navigation details and includes a history stack

Other Controllers

UITabBarController

UITableViewController

AddressBookUI.framework--has several controllers that allow access to address book information

UIIMagePickerController—allows access to photo album and to use the camera

MFMailComposeViewcontroller—allows creation of mail message

GKPeerPickerController—provides GUI for discovering and connecting with other iPhones

MPMediaPickerController—media selection GUI

Recommended