iPhone: UITextField inside TableView cell?
- by Nic Hubbard
I am trying to programatically add a UITextFiled inside one of my tableview cells. How would I do this?
Assuming it is in the following method, what code would I use?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Don't let the user click when not in editing mode
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Title";
// This is where I want to add a text field
cell.detailTextLabel.text = @"test";
cell.editing = YES;
break;
}
return cell;
}