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:
UIRefreshControl *refContr=[[UIRefreshControl alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
[refContr setTintColor:[UIColor blueColor]];
[refContr setBackgroundColor:[UIColor greenColor]];
[self.view addSubview:refContr];
[refContr setAutoresizingMask:(UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleLeftMargin)];
[refContr addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
Then Implemented reachability class notification :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
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.
switch (netStatus)
{
case NotReachable: {
for (UIRefreshControl *subView in [myView subviews]) {
if ([subview isKindOfClass:[UIRefreshControl class]]) {
[subView removeFromSuperview];
}
}
//or you could use [UIRefreshControl setHidden:YES];
connectionRequired = YES;
break;
}
case ReachableViaWiFi: {
for (UIRefreshControl *subView in [myView subviews]) {
if ([subview isKindOfClass:[UIRefreshControl class]]) {
[subview removeFromSuperview];
}else{
[self.view addSubview:refContr];
}
//or you could use [UIRefreshControl setHidden:NO];
break;
}
}
Hope this will work for you.