我有一个包含许多单元格的表格视图。每个单元格都有自己的UITextField。我以编程方式添加了文本字段。我希望当编辑按钮被击中时,每个textField都会出现。 (现在表格处于编辑模式),再次按下时,我希望所有的textField消失(离开编辑模式)。我知道我可以使用hidden
属性做到这一点,但我想在这种方法做这个:将UITextField添加到UITableViewCell只显示最后一个单元格中的textField
- (IBAction)editButton:(id)sender
{
if (self.editing)
{
[self setEditing:NO animated:YES];
[self.myTableView setEditing:NO animated:YES];
EditButton.title = @"Edit";
cellText.hidden = YES; //<-- THIS IS THE CODE
}
else
{
[self setEditing:YES animated:YES];
[self.myTableView setEditing:YES animated:YES];
EditButton.title = @"Done";
cellText.hidden = NO; //<-- THIS IS THE CODE
}
}
,但只显示和隐藏的最后小区的文本字段。我怎样才能将它显示在显示位置,然后不显示每个单元格的textFIeld?提前谢谢了!!!
提前ROW
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cellText = [[UITextField alloc]init];
[cellText setFrame:CGRectMake(190, 15, 55, 30)];
cellText.text = @"1";
cellText.borderStyle = UITextBorderStyleRoundedRect;
cellText.hidden = YES;
cellText.userInteractionEnabled = NO;
[cell addSubview:cellText];
}
return cell;
}
由于CELL! :D
你正在用的cellForRowAtIndexPath method.And一些代码错误,请确保传递每个textField的标签。请发布该方法的一些代码。它确实会帮助我们解决问题。 – 2012-01-12 04:31:13
好的!我会吧!感谢您的帮助! – iProRage 2012-01-12 04:32:06