안녕하세요, 저는 UITableViewCell을 사용자 지정해야합니다. 그래서 나는 그것을 지원하기 위해 커스텀 클래스와 필요한 UI (xib)를 만들었다. XIB의 경우 클래스를 내가 만든 파생 클래스로 선택했습니다. 내 문제는 표시 레이블을 속성에 연결 한 후 런타임에 값을 설정해도 원하는 텍스트가 표시되지 않는 경우입니다. 그것의 공백으로 왼쪽. 아래는 코드 스 니펫입니다. 먼저ios TableViewCell 사용자 지정 문제입니다. 사용자 지정 텍스트 표시 안 함
@interface CustomCell : UITableViewCell
{
IBOutlet UILabel *titleRow;
}
@property (nonatomic, strong) UILabel *titleRow;
@property (nonatomic, strong) UILabel *subTitleRow;
@property (nonatomic, strong) UILabel *otherTextRow;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MedVaultCell";
CustomCell *cell = nil;
cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (nil == cell){
//Load custom cell from NIB file
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellHistoryCell" owner:self options:NULL];
cell = [nib objectAtIndex:0];
//cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
// get the object
Weight *currentCellWeight = [_weights objectAtIndex:indexPath.row];
// Configure the cell...
UILabel *titleLable = [[UILabel alloc]init];
titleLable.text = currentCellWeight.customDispText;
[cell setTitleRow:titleLable];
cell.titleRow.text = currentCellWeight.display;
cell.titleRow.textColor = [UIColor redColor];
//cell.textLabel.text = [[_weights objectAtIndex:indexPath.row] customDispText];
//cell.textLabel.textColor = [UIColor whiteColor];
return cell;
}
사용자 정의 셀 클래스에'cellForRowAtIndexPath'를 넣고 있습니까? –