Occasionally my table view won't be connected to a service to refresh, and in that case, I don't want the UIRefreshControl to be present.
After I add it in viewDidLoad, I've tried hiding it under certain circumstances with setEnabled:
and setHidden:
but neither seems to work.
also you can do something like this:
To hide refresh control and avoid warning Just use
Objective C
[self.refreshControl removeFromSuperview];
Swift
An old question, but I was looking for an answer and nothing worked exactly like I wanted.
This is what worked for me:
Swift 4
I call createRefreshControl() when I want the control created, and removeRefreshControl when I want it removed.
I had to remove the same target I initially added to the refresh control, otherwise it would refresh one time before it was actually removed.
There’s a very simple solution you can try:
[self.refreshControl removeFromSuperview];
Try setting your table view controller's
refreshControl
property to nil.You can not remove the UIRefreshControl using
setEnabled:NO
,so to this you have to remove it from it's superview.I have tried a sample using Reachability class provided by Apple.To add UIRefreshControl you can use this:
Then Implemented reachability class notification :
You can do it by using bool flag to check the connectivity ,Here i'm providing this example using reachability class by apple to check my connectivity.
Hope this will work for you.