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

CHAPTER 9: Navigation Controllers and Table Views

315

Adding a Rows Control Controller Instance

Now, all we need to do is add this controller to the array in BIDFirstLevelController. Single-click BIDFirstLevelController.m, and import the header file for the BIDRowControlsController class by adding the following line of code just before the

@implementation line:

#import "BIDRowControlsController.h"

Then move on and add the following code to viewDidLoad:

- (void)viewDidLoad { [super viewDidLoad];

self.title = @"Root Level";

NSMutableArray *array = [[NSMutableArray alloc] init];

// Disclosure Button

BIDDisclosureButtonController *BIDDisclosureButtonController = [[BIDDisclosureButtonController alloc]

initWithStyle:UITableViewStylePlain]; BIDDisclosureButtonController.title = @"Disclosure Buttons"; BIDDisclosureButtonController.rowImage = [UIImage

imageNamed:@"BIDDisclosureButtonControllerIcon.png"]; [array addObject:BIDDisclosureButtonController]; [BIDDisclosureButtonController release];

// Checklist

BIDCheckListController *checkListController = [[BIDCheckListController alloc] initWithStyle:UITableViewStylePlain];

checkListController.title = @"Check One"; checkListController.rowImage = [UIImage

imageNamed:@"checkmarkControllerIcon.png"]; [array addObject:checkListController]; [checkListController release];

// Table Row Controls

BIDRowControlsController *rowControlsController = [[BIDRowControlsController alloc] initWithStyle:UITableViewStylePlain];

rowControlsController.title = @"Row Controls"; rowControlsController.rowImage = [UIImage imageNamed:

@"rowControlsIcon.png"];

[array addObject:rowControlsController];

self.controllers = array;

}

Save everything, and compile it. This time, you should see yet another row when your application launches (see Figure 9–16).

www.it-ebooks.info

316

CHAPTER 9: Navigation Controllers and Table Views

Figure 9–16. The Row Controls controller added to the root level controller

If you tap this new row, it will take you down to a new list where every row has a button control on the right side of the row. Tapping either the button or the row will show an alert telling you which one you tapped (see Figure 9–17).

www.it-ebooks.info

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