views:

91

answers:

1

I have a working UITableView filled with some options for my app, and i want to add UISwitches to them just like the Settings app, how do i do this?

Thanks :)

+3  A: 

You can create your own custom accessory view. When handling tableView:cellForRowAtIndexPath:, just create a switch in the row cell like this:

UISwitch* turboSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0.0, 0.0, 84.0, 27.0)];
[turboSwitch setOn:[engine.turbo boolValue]];
cell.accessoryView = turboSwitch;
cell.textLabel.text = @"Turbo";

Don't forget to connect the target action to your controller.

gavinb