當我第一次選擇UITableView
的任何一行時,我已經爲單元格添加了UITextField
,現在我想在第二次選中行時刪除該文本字段。如何從單元格中刪除UITextField,何時選中一行?
任何建議或示例代碼將不勝感激。 謝謝!在細胞中添加文本字段
代碼:在cellForAtIndexPath方法
在 didSelectedRowAtIndexPathif (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];
}
selectedRow = indexPath.row;
[mainTable reloadData];
你可以試着更好地解釋你想達到的目標嗎? – shannoga
「UITableView」的一行? –
向我們展示您之前嘗試過的內容,例如將「UITextField」添加到單元格的代碼。 –