[Solved] How to disable a buttons in a custom cell?

Introduction

Disabling buttons in a custom cell can be a tricky task, but it doesn’t have to be. With the right approach, you can easily disable buttons in a custom cell. In this article, we’ll discuss the different methods you can use to disable buttons in a custom cell, as well as provide step-by-step instructions on how to do it. We’ll also discuss the advantages and disadvantages of each method, so you can make an informed decision about which one is best for your needs. So, let’s get started!

Solution

To disable a button in a custom cell, you can use the following code:

// Disable the button
cell.button.enabled = false;

You cannot use dequeue because the return cell is a new instance of the cell and not the cell displayed.

Your are two way for change the button state.

  • Transport your (IBACTION)method in your custom cell class and not in controller class and release legacy code. If you need to update data between CustomCell and controller create and invoke a delegate.

  • The second way is to reload the Cell of UITableView after setting necessary values for presented the well state