When setting the state of a button on a cell based on the information returned, sometimes the button's display state is not the same as the state we set because of the cell's reuse mechanism, which is possible because we set a state based on the returned data, such as:
Click the "Like" button if (model.user_praise) { //If there is a praise_user, the description has been clicked, the button status is set to the state that has been liked cell.likeButton.selected = YES; }
Setting it in the way above may cause the button status to appear unhealthy, and the correct approach is to set both conditions as follows:
Click the "Like" button if (model.user_praise) { //If there is a praise_user, the description has been clicked, the button status is set to the state that has been liked cell.likeButton.selected = YES; } else { cell.likeButton.selected = NO; }
Add button on UITableViewCell, the normal or selected status of the button shows the possible cause of the abnormal.