0

I've done my research and followed the numerous guides for this process, including:

  1. Adding unknown number of rows to 'Static Cells' UITableView
  2. https://devforums.apple.com/message/502990#502990

But a recurring theme in the follow-up questions is always "The TableViewCells show up, but they are empty." I assume people solve the problem, but no solutions are posted.

Thus, the stage I am at consists of: the static cells showing up and being correctly filled with data, and the dynamic cells correctly show up in quantity, but not with their elements (they are empty).

I believe I have everything hooked up correctly. I have:

  1. In my UITableViewController subclass, included and overridden all required methods as marked as "Answer" in the two links above.
  2. Subclassed UITableViewCell, and included two UILabel properties in the subclass.
  3. Set the class for the cell in Storyboard to my subclass, and given an appropriate Identifier, which is correctly used in the Controller subclass.
  4. Placed two UILabels on the cell in storyboard.
  5. Hooked up the two labels to the properties in the Cell subclass.

I instantiate and assign values to the properties just like in the answers above.

static NSString *CellIdentifier = @"DynamicCell";
    OwnersInfoEventsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {
        cell = [[OwnersInfoEventsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    cell.eventName.text = @"Name"; //this doesn't show up
    cell.eventNeed.text = @"Need"; //this doesn't show up
    cell.backgroundColor = [UIColor redColor]; //this works, the cell shows up red
    return cell;

What am I missing?

Community
  • 1
  • 1
user1366911
  • 918
  • 7
  • 20

2 Answers2

0

That happened to me and the problem was that when you create your own cell (in case you don't find a reusable one) its two labels are nil. So you also has to create two labels and set them as the labels of your cell and it would hopefully work.

salman140
  • 1,510
  • 10
  • 11
0

First you need to check that you have defined OwnersInfoEventsCell properly. Check that Label that you defined in Cell Class is properly defined. Check frame of that label.

 _ eventName = [[UILabel alloc]initWithFrame:CGRectMake(25, 2, 40 , 40)];
 _ eventName.backgroundColor = [UIColor clearColor];
 [_ eventName setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
 eventName.font = [UIFont fontWithName:@"King" size:12];
 [self.contentView addSubview:_ eventName ];

check that you have added label in cell's content view. This may be issue. let me show your code of OwnersInfoEventsCell then i can suggest you more briefly.

Hope this may help you.

Nirav Jain
  • 5,088
  • 5
  • 40
  • 61