Reputation: 1827
I would like to add in my ViewController something that should look identical with the first item of this picture (Simple passcode + radio button). Do I need to use a UITableView and define the hearder and the footer for this? Can someone provide me some examples of how to start and work with this?
Upvotes: 0
Views: 790
Reputation: 41226
Simplest solution is to set up a UITableViewController using static layout in interface builder.
Then set up your table however you want it to look:
Upvotes: 0
Reputation: 4735
You need a custom UITableViewCell with a UILabel on the left side of the cell, and a UISwitch on the right side.
Register the custom cell class with the table view and a cell identifier and then customise it as you would any other cell.
static NSString *const CellIdentifier = @"customCell";
/**
* Called after the controller’s view is loaded into memory.
*/
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[CustomCell class] forCellIdentifier:CellIdentifier];
}
/**
* Asks the data source for a cell to insert in a particular location of the table view.
*
* @param tableView A table-view object requesting the cell.
* @param indexPath An index path locating a row in tableView.
*
* @return An object inheriting from UITableViewCell that the table view can use for the specified row.
*/
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = @"Simple Passcode";
return cell;
}
Upvotes: 1