세 개의 테이블보기 셀이있는 테이블보기가 있습니다. 셀을 구성하는 동안 각 셀에 UITextField를 추가하고 모든 텍스트 필드에 자리 표시 자 값을 설정합니다. 테이블 뷰는 최종 결과를로드 은 다음과 같습니다UITextField 자리 표시 자 텍스트 오버레이 문제
난 데 문제는, 내가 "화면 꺼짐"세포 중 하나를 스크롤 할 때 그들이 자리 표시 자 텍스트를 얻을 다시 때이다 여기처럼 어둡고 어두운 :
그때 프로그래밍 방식으로 마지막 셀에 자리 표시 자 값을 변경하여에 이름을 입력하여 UITextField에 문자열 값을 변경하거나 할 때, 그 속성의 이전 값 체류하고 새로운 가치 다음과 같이 셀에 중첩됩니다 : 여기
는 그 세포 구성에 대한 책임이있는 방법이 있습니다 : 제거 같은
당신이 볼 수 있듯이, 내가 시도- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
[self configureCell:cell forIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexPath
{
for (UIView *subview in cell.contentView.subviews) {
[subview removeFromSuperview];
}
cell.backgroundColor = [UIColor whiteColor];
cell.autoresizesSubviews = YES;
cell.clearsContextBeforeDrawing = YES;
CGRect textFieldFrame = cell.bounds;
textFieldFrame.origin.x += 10;
textFieldFrame.size.width -= 10;
UITextField *textField = [[UITextField alloc] initWithFrame:textFieldFrame];
textField.adjustsFontSizeToFitWidth = YES;
textField.textColor = [UIColor lightGrayColor];
textField.enabled = YES;
textField.userInteractionEnabled = NO;
textField.autoresizingMask = UIViewAutoresizingFlexibleWidth;
textField.clearsContextBeforeDrawing = YES;
textField.clearsOnBeginEditing = YES;
if (indexPath.section == ATTAddNewTimerSectionName) {
textField.placeholder = @"Name";
textField.userInteractionEnabled = YES;
textField.delegate = self;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
} else if (indexPath.section == ATTAddNewTimerSectionDate) {
textField.placeholder = @"Date/Time";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else if (indexPath.section == ATTAddNewTimerSectionCalendar) {
if (self.userCalendarEvent == nil) {
textField.placeholder = @"See list of calendar events";
} else {
textField.placeholder = nil;
textField.placeholder = self.userCalendarEvent.title;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
[cell addSubview:textField];
}
여러 가지 모든 하위 뷰를 셀에 추가하거나 셀 및 UITextView에서 [UIView setClearsContextBeforeDrawing : YES]를 설정하고 자리 표시 자 값을 nil로 설정하여 성공하지 못하게합니다.
모든 포인터가 많이 감사하겠습니다!
예, 그게 문제입니다. 자리 표시 자와 텍스트가 겹치는 경우 동일한 위치에> = 2 UITextField가 있기 때문에 가능합니다 – onmyway133