Appendix A. Answers to Exercises

This appendix provides the solutions for the end-of-chapter exercises located at the ends of Chapters 218 (there are no exercises in Chapter 1).

CHAPTER 2 EXERCISE SOLUTIONS

Answer to Question 1

The minimum image size you should design is 72 × 72 pixels. It is all right to design a larger image because the iPad automatically resizes it for you. In general, try to design a larger image because doing so prepares your application for the newer devices that Apple may roll out.

Answer to Question 2

You should implement the shouldAutorotateToInterfaceOrientation: method and code the appropriate statements to support the orientation you want. To support all orientations, simply return a YES in this method. The following code snippet supports the portrait and landscape left modes:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation {
    // Return YES for supported orientations
    // return YES;
    return (interfaceOrientation==UIInterfaceOrientationPortrait ||
interfaceOrientation==UIInterfaceOrientationLandscapeLeft);

}

Answer to Question 3

This is to ensure that the image is always copied into the Resources folder. If not, Xcode only makes a reference to the image and the image is not physically in the Resources folder.

CHAPTER 3 EXERCISE SOLUTIONS

Answer to Question 1

In the .h file:

//---declare an outlet---
IBOutlet UITextField *nameTextField;
//...
//...
//---expose the outlet as a property---
@property (nonatomic, retain) UITextField ...

Get Beginning iPad™ Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.