在我的应用程序中,您可以选择第一部分(第 0 部分)中的两行之一。当您选择一个行时,第 2 节(第 1 节)中的行将重新加载。当您现在多次更改选择时,占位符不会消失。(当您将选择更改 1 或 2 次时,占位符会消失)。我究竟做错了什么?
这是我在单元格中创建 UITextField 的方法:
if (!self.selectedType) {
NSString *string = [NSString stringWithFormat:@"%@: ", self.LessonToDisplay];
int where = (string.length*5)+35;
self.textField = [[UITextField alloc]initWithFrame:CGRectMake(where, 10, 150, 25)];
self.textField.tag = 42;
self.textField.font = [UIFont fontWithName:@"Helvetica-Neue" size:16];
self.textField.textColor = [UIColor blackColor];
if([self.textField.text isEqualToString:@""]){
self.textField.placeholder = @"Beschreibung";
}
[cell.contentView addSubview:self.textField];
cell.textLabel.text = [NSString stringWithFormat:@"%@: ", self.LessonToDisplay];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else {
NSString *string = [NSString stringWithFormat:@"%@: Prüfung", self.LessonToDisplay];
int where = (string.length*5.8)+57;
self.textField2 = [[UITextField alloc]initWithFrame:CGRectMake(where, 10, 150, 25)];
self.textField2.tag = 43;
self.textField2.font = [UIFont fontWithName:@"Helvetica-Neue" size:16];
self.textField2.textColor = [UIColor blackColor];
if([self.textField2.text isEqualToString:@""]){
self.textField2.placeholder = @"Beschreibung";
}
[cell.contentView addSubview:self.textField2];
cell.textLabel.text = [NSString stringWithFormat:@"%@: Prüfung ", self.LessonToDisplay];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}