1

在我的 iPhone 应用程序中,我有一个表格视图。

我希望当用户选择(或基本上触摸)表格视图的单元格时,他/她应该能够编辑单元格内容。

我怎样才能做到这一点?

4

2 回答 2

3

@PARTH 为了使您的 UITableView 单元格可编辑,我建议您将文本字段提供给您的单元格....

例如:- 在

-(UITableViewCell *)reuseTableViewCellWithIdentifier:(NSString *)identifier withIndexPath:(NSIndexPath *)indexPath {


    CGRect cellRectangle = CGRectMake (0, 10, 300, 70); 
    CGRect Field1Frame = CGRectMake (10, 10, 290, 70);
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellRectangle reuseIdentifier:identifier] autorelease];
    UITextField *textField;


    //Initialize Label with tag 1.

    textField = [[UITextField alloc] initWithFrame:Field1Frame];

    textField.tag = 1;
    [cell.contentView addSubview:textField];

[textField release];
    return cell;
}

并在您的cellForRowAtIndexPath方法中 // 配置单元格。

 UITextField *txtTemp = (UITextField *)[cell.contentView viewWithTag:1];

相应地在您的表格视图中使用它,否则隐藏它.....希望它会帮助你!

于 2011-01-13T07:30:32.077 回答
0

您需要使用此链接将文本字段放在表格单元格内。

于 2011-01-13T07:13:09.147 回答