O'Reilly logo

Beginning iPhone® SDK Programming with Objective-C® by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required