I want to create a text field in the group table view cell. If I create one text field in a cell, the text fields are over lapped in all the grouped table view cells. I don’t know how it happened. So I want to create a text field in a grouped table view cell (Not all the cells). How can I achieve this? Is there any sample code available?
Here my sample code,
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UITextField * lastname = [[UITextField alloc] initWithFrame:CGRectMake(120, 5, 150, 35)];
lastname.tag = titleTag2;
[cell.contentView addSubview:lastname];
lastname.delegate = self;
lastname.returnKeyType = UIReturnKeyDefault;
}
}
just in case anyone comes across this question, this is how you add UITextFields to a group table.
In the UITableViewController (which I assume is the table’s delegate & datasource) implement the following functions:
Obviously, you’ll still need to implement the UITextFieldDelegate methods to actually process the text entry and moving the first responder between fields.
UPDATE: Since posting this, I realised that you can use the UIControl contentVerticalAlignment property, and set that to UIControlContentVerticalAlignmentCenter, in which case you can just set your frame to the bounds of the cell’s content view.