I’ve added a UITextField to cell whenever any row of UITableView is first time selected, now i want to remove that text field when row get selected second time.
Any suggestion or sample code will be appreciated.
Thanks!!
Code for adding Text field in cell: in cellForAtIndexPath method
if (indexPath.row == selectedRow)
{
numOfBottles =[[UITextField alloc] initWithFrame:CGRectMake(240,9.0f,50, 25)];
numOfBottles.tag = indexPath.row;
[numOfBottles setBorderStyle:UITextBorderStyleNone];
[numOfBottles setBackgroundColor:[UIColor clearColor]];
[numOfBottles setTextColor:[UIColor whiteColor]];
[numOfBottles setTextAlignment:UITextAlignmentLeft];
[numOfBottles setBackground:[UIImage imageNamed:@"blue_dropdown_normal.png"]];
[numOfBottles setFont:[UIFont systemFontOfSize:16.0f]];
[numOfBottles setDelegate:self];
NSString* quantity = [[NSString alloc] initWithString:[subtotalObj.qtyArray objectAtIndex:(indexPath.row - 1)]];
[numOfBottles setText:quantity];
[numOfBottles setTextAlignment:UITextAlignmentCenter];
[numOfBottles setBackgroundColor:[UIColor whiteColor]];
numOfBottles.keyboardType = UIKeyboardTypeDefault;
numOfBottles.tag = indexPath.row;
[cell.contentView addSubview:numOfBottles];
[numOfBottles release];
}
in didSelectedRowAtIndexPath
selectedRow = indexPath.row;
[mainTable reloadData];
I strongly recommend you to create own UITableViewCell subclass.
In this class add this UITextView object and, it the method
- (void)setSelected:(BOOL)selected animated:(BOOL)animatedshow/hide your textField.