Appendix A. Answers to Exercises
This appendix provides the solutions for the end-of-chapter exercises located at the end of each chapter, except Chapter 1.
CHAPTER 2 EXERCISE SOLUTIONS
Answer to Question 1
The minimum image size you should design is 57 × 57 pixels. It is all right to design a larger image because the iPhone 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, like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { // Return YES for supported orientations return YES; }
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 *nameTextField;
In the .m
file:
@implementation BasicUIViewController
//---generate the getters and setters for the property---
@synthesize nameTextField;
Answer to Question 2
In the .h
file:
- (IBAction)btnClicked:(id)sender;
In the .m
file:
@implementation BasicUIViewController //... //...- (IBAction)btnClicked:(id)sender {
//---your code for the action here---
}
CHAPTER 4 EXERCISE SOLUTIONS
Answer to Question ...
Get Beginning iPhone® SDK Programming with Objective-C® 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.