P. 1
iPhone App Programming Guide

iPhone App Programming Guide

|Views: 282|Likes:
Published by Lukasz81

More info:

Published by: Lukasz81 on Aug 22, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/22/2011

pdf

text

original

This section contains a tutorial that shows you how to configure a Settings page to display the controls you
want. The goal of the tutorial is to create a page like the one in Figure 5-3. If you have not yet created a
settings bundle for your project, you should do so as described in “Preparing the Settings Page for
Editing” (page 78) before proceeding with these steps.

Creating and Modifying the Settings Bundle

79

2010-11-15 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER5

Implementing Application Preferences

Figure5-3 A root Settings page

1. Disclose the Preference Items key to display the default items that come with the template.

2. Change the title ofItem 0 toSound.

■ DiscloseItem 0 ofPreference Items.

■ Change the value of theTitle key fromGroup toSound.

■ Leave theType key set toGroup.

3. Create the first toggle switch for the newly renamed Sound group.

■ SelectItem 2 (the toggle switch item) ofPreference Items and choose Edit > Cut.

■ SelectItem 0 and choose Edit > Paste. (This moves the toggle switch item in front of the text field

item.)

■ Disclose the toggle switch item to reveal its configuration keys.

■ Change the value of theTitle key toPlay Sounds.

■ Change the value of theIdentifierkey toplay_sounds_preference. The item should now be

configured as shown in the following figure.

80

Creating and Modifying the Settings Bundle

2010-11-15 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER5

Implementing Application Preferences

4. Create a second toggle switch for the Sound group.

■ SelectItem 1 (the Play Sounds toggle switch).

■ Select Edit > Copy.

■ Select Edit >Paste. This places a copy of the toggle switch right after the first one.

■ Disclose the new toggle switch item to reveal its configuration keys.

■ Change the value of itsTitle key to3D Sound.

■ Change the value of itsIdentifier key to3D_sound_preference.

At this point, you have finished the first group of settings and are ready to create the User Info group.

5. ChangeItem 3 into a Group control and name itUser Info.

■ ClickItem 3inthePreferences Items.Thisdisplaysadrop-downmenuwithalistofitemtypes.

■ From the drop-down menu, selectGroup to change the type of the control.

■ Disclose the contents ofItem 3.

■ Set the value of theTitle key toUser Info.

6. Create the Name field.

■ SelectItem 4 in thePreferences Items.

Creating and Modifying the Settings Bundle

81

2010-11-15 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER5

Implementing Application Preferences

■ Using the drop-down menu, change its type toText Field.

■ Set the value of theTitle key toUser Info.

■ Set value of theIdentifier key touser_name.

■ Toggle the disclosure button of the item to hide its contents.

7. Create the Experience Level settings.

■ SelectItem 4 and click the plus (+) button (or press Return) to create a new item.

■ Click the new item and set its type toMulti Value.

■ Disclose the items contents and set its title toExperience Level, its identifier to

experience_preference, and its default value to0.

■ With the Default Value key selected, click the plus button to add aTitles array.

■ Open the disclosure button for theTitles array and click the items button along the right edge

of the table. Clicking this button adds a new subitem toTitles.

■ Select the new subitem and click the plus button 2 more times to create 3 total subitems.

■ Set the values of the subitems toBeginner,Expert, andMaster.

■ Select theTitles key again and click its disclosure button to hide its subitems.

■ Click the plus button to create theValues array.

■ Add 3 subitems to theValues array and set their values to0,1, and2.

■ Click the disclosure button ofItem 5 to hide its contents.

8. Add the final group to your settings page.

■ Create a new item and set its type toGroup and its title toGravity.

■ Create another new item and set its type toSlider, its identifier togravity_preference, its

default value to1, and its maximum value to2.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->