Graphics Programs Reference
In-Depth Information
NSLog(@"Going to show the image for %@", ip);
}
Build and run the application. Tap a thumbnail (or, more accurately, the clear button on
top of the thumbnail) and check the message in the console.
All of this code may seem like overkill, and for one message, it really is. However, this
approach has bought us two things: the decoupling the cell from the controller and a gen-
eral purpose format for cells to relay messages to their controller. In the Silver Challenge
for this exercise, you will see how easy it is to use this technique in a general way to give
all of your cells the ability to relay messages.
Presenting the image in a popover controller
Now, ItemsViewController needs to change showImage:atIndexPath: to
grab the BNRItem associated with the cell whose button was tapped and display its im-
age in a UIPopoverController .
To display an image in a popover, you need a UIViewController whose view shows
an image as the popover's content view controller. Create a new UIViewController
subclass from the UIViewController template. Name this new class
ImageViewController , select UIViewController as its superclass, and check
only the With XIB for user interface box.
Open ImageViewController.xib . First, drag a UIScrollView onto the View .
Then, drag a UIImageView onto the UIScrollView .
Figure 15.11 ImageViewController XIB
 
Search WWH ::




Custom Search