views:

559

answers:

1

Does anyone have a simple tutorial on how to easily add a TextView to a TableView? Basically re-creating a Settings-style grouped tableview type thing.

A: 

This is where we setup the object that we want to create, in this example, Im creating a UISwitch; serverSecureAction is where we will put what we want to happen when the switch is triggered.

    serverSecure = [[[UISwitch alloc] initWithFrame:CGRectMake(197, 8, 94, 27)] autorelease];
    serverSecure.tag = kServerTag;
    [serverSecure addTarget:self action:@selector(serverSecureAction:) forControlEvents:UIControlEventValueChanged];
    serverSecure.backgroundColor = [UIColor clearColor];


switch (indexPath.row)
{
 case 0:
 {
        //This is where we add the subview we created above, this can be used for any time of object
     [cell.contentView addSubview:serverSecure];
     cell.textLabel.text = NSLocalizedString(@"Connect Secure", @"");
     serverSecure.on = TRUE;
     break;
 }
 }
AWright4911