사용자 정의 셀이있는 UITableView가 있습니다. 셀 안에는 자리 표시 자 텍스트가있는 UITextField가 있습니다. 내가 cellForRowAtIndexPath에서 자리 표시자를 설정하고 싶습니다만, 설정하려고 할 때 자리 표시자는 (null)이라고 말합니다. 또한, 그 자리 표시 자로 서식을 싶습니다 "기간 (셀 번호를 tableView)"그래서 tableView 맨 가장 가까운 셀에 대한 "기간 1"말할 것이라고, 위쪽에서 두 번째 말할 것이라고 "기간 2". 번호 매기기를하는 방법이나 셀이 null을 인쇄하는 이유를 알아낼 수 없습니다. 사용자 지정 셀에cellForRowAtIndexPath의 셀에 UITextField 자리 표시 자 설정
- -
NSString *rowString = [NSString stringWithFormat:@"Period %@", self.rowNumber];
self.classText = [[UITextField alloc] init];
self.classText.delegate = self;
self.classText.placeholder = rowString;
self.classText.frame = CGRectMake(14, 3, 320, 40);
self.classText.keyboardAppearance = UIKeyboardAppearanceDark;
self.classText.font = [UIFont fontWithName:@"HelveticaNeue" size:17];
//[self.classText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[self addSubview:self.classText];
cellForRowAtIndex 경로에서 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SchoolCell *cell = nil;
static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
if (cell == nil) {
cell = [[SchoolCell alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.rowNumber = @"test";
return cell;
}
어떤 기능으로 텍스트 필드를 만드나요? 코드가 나열되어 있지만 참조 할 때 참조가 없습니다. – Putz1103
셀 @ Putz1103에서 – matthew