您好我有一個要求來定製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