Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Designing Interfaces > Walkthrough: Building a Converter Interface by Hand

Walkthrough: Building a Converter Interface by Hand

Anything that can be designed in Interface Builder can be implemented directly using Objective-C and Cocoa Touch. The code in Listing 4-2 duplicates the converter project you just built. Instead of loading an interface from a storyboard file, it manually lays out the elements in the loadView method.

The code matches the approach you used in Interface Builder. It adds two labels and two text fields. It sets the label texts to Fahrenheit and Celsius, tells the first field to use a numbers-and-punctuation keyboard, and disables the second. The locations and sizes for these items use view frames derived from the previous walkthrough.

To finish the layout, it adds a Convert button to the navigation bar. The button uses the same convert: callback as the IB project and calls the same code.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint