自定义单元格文本字段不可编辑
Custom Cell textfield non editable
我有一个自定义单元格,其中有两个文本字段。我有一个对象列表,我在每个单元格上填充它们。默认情况下,文本字段是可编辑的,但是我想知道如何使第一行第一个文本字段不可编辑。
in cellForRowAtIndexPath
检查 indexPath
是第 0 节和第 0 行。如果是这样,将 textField
s enabled
属性 设置为 NO
/ false
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
cell.endabled = YES;
if(indexPath.section==0 && indexPath.row==0)
{
cell.customTextField.enabled = NO;
}
return cell;
}
我有一个自定义单元格,其中有两个文本字段。我有一个对象列表,我在每个单元格上填充它们。默认情况下,文本字段是可编辑的,但是我想知道如何使第一行第一个文本字段不可编辑。
in cellForRowAtIndexPath
检查 indexPath
是第 0 节和第 0 行。如果是这样,将 textField
s enabled
属性 设置为 NO
/ false
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
cell.endabled = YES;
if(indexPath.section==0 && indexPath.row==0)
{
cell.customTextField.enabled = NO;
}
return cell;
}