iPhone: UITextField inside TableView cell?
Posted
by Nic Hubbard
on Stack Overflow
See other posts from Stack Overflow
or by Nic Hubbard
Published on 2010-05-24T00:05:22Z
Indexed on
2010/05/24
0:10 UTC
Read the original article
Hit count: 434
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;
}
© Stack Overflow or respective owner