IOS: Maintaining button state in uitableviewcell

前端 未结 3 810
天涯浪人
天涯浪人 2021-01-14 09:28

I have an iPhone app problem that\'s been bugging me for a few days and it really doesn\'t seem like it should be this difficult so I\'m sure I\'m missing something obvious.

3条回答
  •  暖寄归人
    2021-01-14 10:26

    The problem is that every time you create or reuse a cell you're giving it a new like button, so when you reuse a cell where the like button has been activated, you're giving it a deactivated like button but the old, activated like button is still there as well.

    Instead of creating a like button every time you need a cell, you should just be setting the state of an existing like button. See the answers to this question for some possible ways of handling that.

提交回复
热议问题