05-Views

05-Views - CS193P - Lecture 5 iPhone Application...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
CS193P - Lecture 5 iPhone Application Development Views Drawing Animation
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Announcements Assignment 3 due Tuesday, 4/21 Friday session is a special, super-mega office hour featuring Troy and Paul To sign up for cs193p-auditors@lists.stanford.edu : https:/mailman.stanford.edu/mailman/listinfo/cs193p-auditors $10,000 scholarship for best applications http://att.com/higherEDcontest
Background image of page 2
Questions from Monday? Model, View, Controller Delegate Allows one object to act on behalf of another object Target-Action
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Today’s Topics Views Drawing Animation
Background image of page 4
Views
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically every view has one superview every view has zero or more subviews
Background image of page 6
View Hierarchy - UIWindow Views live inside of a window UIWindow is actually just a view adds some additional functionality specific to top level view One UIWindow for an iPhone app Contains the entire view hierarchy Set up by default in Xcode template project
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
View Hierarchy - Manipulation Add/remove views in IB or using UIView methods - (void) addSubview :(UIView *)view; - (void) removeFromSuperview ; Manipulate the view hierarchy manually: - (void) insertSubview :(UIView *)view atIndex :(int)index; - (void) insertSubview :(UIView *)view belowSubview :(UIView *)view; - (void) insertSubview :(UIView *)view aboveSubview :(UIView *)view; - (void) exchangeSubviewAtIndex :(int)index withSubviewAtIndex :(int)otherIndex;
Background image of page 8
View Hierarchy - Ownership Superviews retain their subviews Not uncommon for views to only be retained by superview Be careful when removing! Retain subview before removing if you want to reuse it Views can be temporarily hidden theView. hidden = YES;
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
View-related Structures CGPoint location in space: { x , y } CGSize dimensions: { width , height } CGRect location and dimension: { origin , size }
Background image of page 10
Rects, Points and Sizes CGSize width 144 height 72 CGRect origin size CGPoint x 80 y 54 72 144 80 54 (0, 0) x y
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
View-related Structure Creation Function Example CGPointMake (x, y) CGPoint point = CGPointMake (100.0, 200.0); point.x = 300.0; point.y = 30.0; CGSizeMake (width, height) CGSize size = CGSizeMake (42.0, 11.0); size.width = 100.0; size.height = 72.0; CGRectMake (x, y, width, height) CGRect rect = CGRectMake (100.0, 200.0, 42.0, 11.0); rect.origin.x = 0.0; rect.size.width = 50.0;
Background image of page 12
UIView Coordinate System + x + y UIView 0, 0 Origin in upper left corner y axis grows downwards
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
View’s location and size expressed in two ways Frame is in superview’s coordinate system Bounds is in local coordinate system View A View B 0, 0 550 400 View A frame : origin: 0, 0 size: 550 x 400 View A bounds : origin: 0, 0 size: 550 x 400
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/29/2009 for the course CS 193D taught by Professor Staff during the Spring '08 term at Stanford.

Page1 / 55

05-Views - CS193P - Lecture 5 iPhone Application...

This preview shows document pages 1 - 15. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online