0
누구든지 아래에서 아이디어가 있습니까? 이 오류는 아래쪽의 행 6 & 8 번에서 발생합니다. 라벨을 합성했습니다. 건배.오류 : 'label1'속성이 'UITableViewCell'유형의 개체에서 발견되지 않았습니다.
cell._label1.text = [NSString stringWithFormat:p.no ];
cell._label2.text = [NSString stringWithFormat: p.name ];
사용 : 대신
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateStyle:NSDateFormatterShortStyle];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 12, 240, 20)];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(250, 12, 50, 20)];
label1.text = @"Left";
label2.text = @"Right";
[cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];
// Configure the cell...
President *p = (President *)[self.importedRows objectAtIndex:indexPath.row];
cell._label1.text = [NSString stringWithFormat:p.no ];
cell._label2.text = [NSString stringWithFormat: p.name ];
return cell;
}
'if (cell == nil)'블록 안에 셀당 한 번만 추가 레이블을 추가해야합니다. – rmaddy