custom uitableviewcell will not display label texts

前端 未结 1 1813
广开言路
广开言路 2021-01-23 17:08

And the value of the labels are null as well.

I\'m not really sure what\'s going on.

These are my classes/codes

@interface CustomEventCell : UIT         


        
相关标签:
1条回答
  • 2021-01-23 17:23

    I wrote a simple little test app attempting to replicate what you want to see working. I have made it available here using Storyboards. If you cannot figure it out from this, then perhaps you can take the test app and modify it so that it replicates the bad behavior you are seeing.

    My best guess as to what might be going on is that when you initialize your cell, it is not connected to a view in a xib.

    Try setting a breakpoint at:

    cell.participant1label.text = event.participant1;
    

    and verify that cell.participant1label is not nil by doing:

    NSLog( @"cell.participant1label: %@", cell.participant1label );
    

    I had a small bug in which none of my custom labels were showing up and cell.participant1label was nil. The cause was that I had not set the Identifier for the custom table view cell to 'EventCell'. So, I might suggest rechecking that and making sure the identifier really does match between your code and the XIB.

    0 讨论(0)
提交回复
热议问题