Uitableview 原型单元赢得';不显示内容

Uitableview 原型单元赢得';不显示内容,uitableview,ios7,custom-cell,Uitableview,Ios7,Custom Cell,我在故事板中设计了一个单元格,然后创建了一个自定义UITableViewCell子类(BasicCell)并将其分配给它。还要设置正确的标识符。我在那个类中创建了自定义单元格的出口。然后在我的UITableViewController子类(我有两种类型的原型单元格)中,单元格内容不会显示。我做错了什么 BasicCell.h @interface BasicCell : UITableViewCell @property (strong, nonatomic) IBOutlet UILabel

我在故事板中设计了一个单元格,然后创建了一个自定义UITableViewCell子类(BasicCell)并将其分配给它。还要设置正确的标识符。我在那个类中创建了自定义单元格的出口。然后在我的UITableViewController子类(我有两种类型的原型单元格)中,单元格内容不会显示。我做错了什么

BasicCell.h

@interface BasicCell : UITableViewCell

@property (strong, nonatomic) IBOutlet UILabel *scorevalue;

@property (strong, nonatomic) IBOutlet UILabel *avgvalue;

@property (strong, nonatomic) IBOutlet UILabel *rankvalue;

@property (strong, nonatomic) IBOutlet UILabel *scorelabel;
@property (strong, nonatomic) IBOutlet UILabel *categorylabel;

@property (strong, nonatomic) IBOutlet UILabel *ranklabel;

@end
TableViewController.m

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     static NSString *CellIdentifierBasic = @"basic";
     static NSString *CellIdentifierDetailed = @"detailed";

    UITableViewCell *cell;

    if(indexPath.row==0){
        // Create first cell

        cell = [[BasicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierBasic];


    }

    else{

        // Create all others

        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierDetailed forIndexPath:indexPath];
    }


    // Configure the cell...

    switch ([indexPath row])
    {
        case 0:
        {

            BasicCell *basicCell = (BasicCell *)cell;

            basicCell.scorelabel.text = @"test";
            basicCell.categorylabel.text = @"test";
            basicCell.ranklabel.text = @"test";

            basicCell.scorevalue.text = @"test";
            basicCell.avgvalue.text = @"test";
            basicCell.rankvalue.text = @"test";



        }
    }
在你的故事板上

  • 创建两个原型单元
  • 更改一个原型单元的自定义类。设置它
    BasicCell
  • 确保为每种类型的单元格设置了适当的单元格标识符
  • 如果是indexPath.row==0,则不要alloc init,但使用适当的标识符将其出列 它应该会起作用


    注意:您应该声明您的IBOutlet为弱而不是强。Cell的视图已经强有力地指向了它们。你不必拥有它们。

    4。这就是问题所在。非常感谢。