Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning iOS5 Development.pdf
Скачиваний:
7
Добавлен:
09.05.2015
Размер:
15.6 Mб
Скачать

104

CHAPTER 4: More User Interface Fun

Figure 4–26. The round rect button, once placed and resized, will completely obscure the two switches.

Double-click the newly added button and give it a title of Do Something.

Connecting and Creating the Button Outlets and Actions

Control-drag from the new button to the assistant editor, just below the last outlet already in the header. When the popup appears, create a new outlet called doSomethingButton. After you’ve done that, control-drag from the button a second time to just above the @end declaration. This time, instead of creating an outlet, create an action called buttonPressed:.

If you save your work and take the application for a test drive, you'll see that the segmented control will be live, but it doesn't do anything particularly useful yet. We need to add some logic to make the button and switches hide and unhide.

We also need to mark our button as hidden from the start. We didn't want to do that before because it would have made it harder to connect the outlets and actions. Now that we’ve done that, let’s hide the button. We’ll show the button when the user taps the right side of the segmented control, but when the application starts, we want the button hidden. Press 4 to bring up the attributes inspector, scroll down to the View section, and click the Hidden checkbox. The button will disappear.

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]