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

CHAPTER 10: Storyboards

363

need to write any code to tell the table view about these cell prototypes. Instead, any table view loaded from a storyboard automatically has access to its associated cell prototypes. Just as with the registered-nib variety, the table view will create such cells on the fly when you ask it using the dequeueReusableCellWithIdentifier: method, so there’s no need to check for a nil return value there, which makes the rest of this method pretty simple.

Click the Run button to see this in action (see Figure 10-6). The app launches and displays our entire task list, with the URGENT-flagged items shown in red. Note that the code doesn’t know or care about the color or font shown in each cell. In fact, it knows almost nothing about the cells it uses! It assumes only that each cell contains a UILabel with a tag of 1. That way, the GUI is pretty well decoupled from the controller code, which means that we can easily change the look of the table view cells without messing with the source code.

Figure 10-6. Running our custom cell storyboard app. Notice the use of the two different cell types. Best get to cleaning that hidden lair, eh?

Will It Load?

It’s probably worth mentioning here that the creation of the BIDTaskListController and its corresponding view happened in a different way than what you may be used to. Up until now, every time we’ve wanted to display a view controller, we’ve created it

www.it-ebooks.info

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