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

CHAPTER 7: Tab Bars and Pickers

169

Custom picker with images: Last, but most certainly not least, we’re going to have some fun with the fifth content view. We’ll demonstrate how to add image data to a picker, and we’re going to do it by writing a little game that uses a picker with five components. In several places in Apple’s documentation, the picker’s appearance is described as looking a bit like a slot machine. Well, then, what could be more fitting than writing a little slot machine game (see Figure 7–6)? For this picker, the user won’t be able to manually change the values of the components, but will be able to select the Spin button to make the five wheels spin to a new, randomly selected value. If three copies of the same image appear in a row, the user wins.

Figure 7–6. Our fifth component picker. Note that we do not condone using your iPhone as a tiny casino.

Delegates and Data Sources

Before we dive in and start building our application, let’s look at what makes pickers more complex than the other controls you’ve used so far. With the exception of the date picker, you can’t use a picker by just grabbing one in the object library, dropping it on your content view, and configuring it. You also need to provide each picker with both a picker delegate and a picker data source.

www.it-ebooks.info

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