UITableView Custom Cells Disappearing content after Scrolling

前端 未结 10 1143
滥情空心
滥情空心 2020-12-17 00:12

I have seen this being asked here many times but none of the solutions worked for me. Here is my code snippet:

- (UITableViewCell *)tableView:(UITableView *)         


        
相关标签:
10条回答
  • 2020-12-17 00:34

    I had a similar issue several times. It is very disturbing since it might be anything. From wrong layout constraints to much serious problems. In first case: in UITableViewCell I had

    contentView.translatesAutoresizingMaskIntoConstraints = false
    

    After removing this line everytnig went to normal.

    In seconds case: I had wrong layout constraint set programmatically:

    stackView.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 16)
    

    The stack element supposed to be set to Top, not to Bottom. After fixing this line everything went normal.

    0 讨论(0)
  • 2020-12-17 00:35

    This behavior in TableView had got me head banging literally. Turns out I had used

    @property (weak, nonatomic) NSMutableArray *itemsArray;
    

    instead of

    @property (strong, nonatomic) NSMutableArray *itemsArray;
    

    Hope this information helps.

    0 讨论(0)
  • 2020-12-17 00:39

    The problem went away when either:

    1. The table view contains many cells (10+),

    2. Each cell has a height of more than 50.

    Weird.

    0 讨论(0)
  • 2020-12-17 00:41

    I know this question already has an answer, but just for googlers:

    In my case the problem was that the views were still in the UITableViewCell but after scrolling due to a mistake in the frame property of the views, they went under the next UITableViewCell and I could not see them.

    I think as the accepted answer has clearly said that :

    The problem went away when either:

    • The table view contains many cells (10+),

    • Each cell has a height of more than 50.

    he had similar problem to mine.

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