08-TableViews

08-TableViews - CS193P - Lecture 8 iPhone Application...

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

View Full Document Right Arrow Icon
CS193P - Lecture 8 iPhone Application Development Scroll Views & Table Views
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 Presence 1 due tomorrow (4/28) ! Questions? Presence 2 due next Tuesday (5/5)
Background image of page 2
Announcements Enrolled students who requested iPod touches can pick them up after class today ! Need Student ID ! No grade if not returned!
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 Scroll views Table views ! Displaying data ! UITableViewController Table view cells Presence - Part 2
Background image of page 4
Scroll 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
UIScrollView For displaying more content than can fit on the screen Handles gestures for panning and zooming Noteworthy subclasses: UITableView and UITextView
Background image of page 6
Scrolling Examples
Background image of page 7

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

View Full DocumentRight Arrow Icon
Using a Scroll View Create with the desired frame Add subviews (frames may extend beyond scroll view frame) Set the content size scrollView. contentSize = CGSizeMake(500, 500); CGRect frame = CGRectMake(0, 0, 200, 200); scrollView = [[UIScrollView alloc] initWithFrame:frame]; frame = CGRectMake(0, 0, 500, 500); myImageView = [[UIImageView alloc] initWithFrame:frame]; [scrollView addSubview :myImageView];
Background image of page 8
Frame and Content scrollView.frame
Background image of page 9

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

View Full DocumentRight Arrow Icon
Frame and Content scrollView.contentSize
Background image of page 10
Frame and Content scrollView.contentOffset
Background image of page 11

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

View Full DocumentRight Arrow Icon
Demo: Using a UIScrollView
Background image of page 12
Extending Scroll View Behavior Applications often want to know about scroll events ! When the scroll offset is changed ! ! When deceleration begins & ends
Background image of page 13

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

View Full DocumentRight Arrow Icon
Extending with a Subclass Create a subclass Override methods to customize behavior Issues with this approach ! Application logic and behavior is now part of a View class ! Tedious to write a one-off subclass for every scroll view instance ! Your code becomes tightly coupled with superclass
Background image of page 14
Extending with Delegation Delegate is a separate object Clearly defined points of responsibility ! Change behavior ! Customize appearance Loosely coupled with the object being extended
Background image of page 15

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

View Full DocumentRight Arrow Icon
UIScrollView Delegate @protocol UIScrollViewDelegate<NSObject> @optional // Respond to interesting events - (void)scrollViewDidScroll:(UIScrollView *)scrollView; ... // Influence behavior - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView; @end
Background image of page 16
Implementing a Delegate Conform to the delegate protocol Implement all required methods and any optional methods @interface MyController : NSObject < UIScrollViewDelegate > - (void)scrollViewDidScroll:(UIScrollView *)scrollView { // Do something in response to the new scroll position if (scrollView. contentOffset ...) { } }
Background image of page 17

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

View Full DocumentRight Arrow Icon
Zooming with a Scroll View Set the minimum, maximum, initial zoom scales Implement delegate method for zooming
Background image of page 18
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 64

08-TableViews - CS193P - Lecture 8 iPhone Application...

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

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