Graphics Programs Reference
In-Depth Information
Relaying Actions from UITableViewCells
Sometimes, it is useful to add a
UIControl
or one of its subclasses, like a
UIButton
, to
a
UITableViewCell
. For instance, we want users to be able to tap the thumbnail image
in a cell and see a full-size image for that item. In this section, we'll do that by adding a
clear button on top of the thumbnail. Tapping this button will show the full-size image in a
UIPopoverController
when the application is running on an iPad.
Open
HomepwnerItemCell.xib
and drag a
UIButton
on top of the
UIImageView
that is already there. Resize this button to match the exact width and height of the
UIImageView
.
Then, Option-click on
HomepwnerItemCell.h
to open it in the assistant editor.
Control-drag from the button to the method area of this file and configure this connection
as shown in
Figure 15.9
.
Figure 15.9 Button connection
This connection will add the following code to
HomepwnerItemCell.h
.
- (IBAction)showImage:(id)sender;
Obviously, we don't want this button to obscure the image underneath it. In the attributes
inspector, change the button's type to
Custom
(
Figure 15.10
).
Figure 15.10 Setting a UIButton's type