您好我有一个要求来定制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'放入自定义单元类中? – 2012-08-13 18:35:01