iosswiftuitableviewuirefreshcontroluicontrol

UIRefreshControl can’t be disabled


I have a UITableViewController inside a storyboard. I’ve enabled the pull to refresh property using interface builder. I would like to disable and re enable the pull to refresh functionality programmatically upon request.

UIRefreshControl inherits from UIControl which have the isEnabled property.

Setting this property to false NEVER disables it, nor setting isUserInteractionEnabled to false.

The only way I can achieve what I want is by setting the refresh control to nil and then re create it again, but I still don’t understand why can’t I just set it’s isEnabled value to false?

Am I missing something here?


Solution

  • You are correct that UIRefreshControl inherits from UIControl, but isEnabled = false, disables touch events. So the only way to "disable" UIRefreshControl is to set it to nil