CS 185C/286 - Lecture 14

Cay S. Horstmann
Lecture 14 Quiz 1
To which protocol does numberOfRowsInSection
belong?
- BIDViewController
- UIViewController
- UITableViewDataSource
- UITableViewDelegate
Lecture 14 Quiz 2
The author added images to each cell by calling
UIImage *image = imageNamed:@"star.png";
cell.imageView.image = image;
Which of the following is true?
- The author defined properties
imageView
and image
- The author defined the
imageView
property, but every image view has an image
property
- The author defined the
image
property, but every cell has an imageView
property
- The author didn't define either property.
Today's Lecture/Lab
Tables
UITableViewDelegate
describes visual appearance, manipulation options
UITableViewDataSource
describes contents of table (2 required methods)
numberOfRowsInSection
gives rows in a particular section
cellForRowAtIndexPath
gives UITableViewCell
for NSIndexPath
- Need reuse identifiers for enabling cell reuse. Can use same identifier if all cells look the same.
Reading Before Next Class

- Read chapter 9 in Beginning iOS 5 Development up to (but not including) "Second Subcontroller: The Checklist"
Lab

- Bring your laptop to the lab
- You will work with a buddy
- For this lab, match yourself up with a buddy who has a Mac
- I want you to submit your lab code to git. But don't use the git support in the IDE.
- Instead, tell XCode to put your (unmanaged) project into the
workspace/lab14
directory.
Simple Tables
- Follow the iPhone programming book Chapter 8, Implementing a Simple Table
- Add a table view as described.
- Wire the controller as described. Which methods belong to the
UITableViewDelegate
protocol and which to UITableViewDataSource
?
- Go on to the section "Adding an image". Just use this image.
- Now use this image for the Disney dwarves (up to Dopey), and the other image for the Tolkien dwarves. How do you do that?