Reputation: 6395
How to add label and textfiled to each row in the UITableview. can i add it through the Interface builder or have to do in the code,
Thanks, Sam.
Upvotes: 0
Views: 297
Reputation: 13346
You can either make a custom table view cell class yourself, or you can use one of the built-in cell styles. Apple's "Settings" panel, for example, uses UITableViewCellStyleValue1
.
Then you would set the detailTextLabel to the text, and add a sub view (your text field) to the contentView for your cell.
static NSString *CellID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellID] autorelease];
}
cell.detailTextLabel.text = @"a title";
[cell.contentView addSubview: xyz]; // xyz = your text field
Upvotes: 2