UIRefreshControl Stuck After Switching Tabs in UITabBarController

I have a UITableViewController as the root view controller in a UINavigationController, which is in turn one of the view controllers in a UITabBarController. All hooked up in Storyboard.

I've configured the UIRefreshControl for my table in Storyboard as well, and normally it looks like it should when pulling:

However, if I switch between my other tabs once or twice, it looks like this:

It's not spinning or anything, just stuck "full", and it stays that way until I pull fully and trigger a refresh.

Any ideas or suggestions appreciate.

user2009606 was almost right, I fixed it by calling

[refreshControl endRefreshing];

On

viewWillAppear:

The refreshControl now behaves properly after switching tabs, independent of its state.

Refresh spinner freeze when switching tabs · Issue #1653 , viewWillAppear(animated) //fixes bug with refreshControl freezing while switching tabs if tableView.contentOffset.y < 0 { tableView.contentOffset = .zero } }​  I’ve configured the UIRefreshControl for my table in Storyboard as well, and normally it looks like it should when pulling: However, if I switch between my other tabs once or twice, it looks like this: It’s not spinning or anything, just stuck “full”, and it stays that way until I pull fully and trigger a refresh.

I know this is incredibly late, but I figure better late than never.

Unfortunately, none of the given answers worked for me. The only thing that worked was this awful piece of code in viewWillAppear:

self.refreshControl = nil;
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refreshFunction) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;

Basically I recreate the UIRefreshControl every time the view is going to appear. It works, albeit while giving the following warning:

Attempting to change the refresh control while it is not idle is strongly discouraged and probably won't work properly.

I'm honestly surprised this is still an issue (still seeing this in iOS 9 now). Hopefully this may be helpful to some other people.

UIRefreshControl+Stuck+After+Switching+Tabs+in+ , UIRefreshControl Stuck After Switching Tabs in UITabBarController I've configured the UIRefreshControl for my table in Storyboard as well,  UIRefreshControl Stuck After Switching Tabs in UITabBarController (10) After running into the same problem several times I decided to make a library for it SwiftPullToRefresh.

To sum up and provide a complete solution.

The problem:

If UIRefreshControl is animating during screen transition, it will stay visible but will not be animating. Video https://vid.me/Bkb7

Also, if pull to refresh animation was started but not completed, and then transition was performed, UIRefreshControl will be hidden but stuck. Video https://vid.me/Bkb7

Solution:

Start UIRefreshControl animation on viewWillAppear and end it on viewDidDisappear. Save the state of refresh process to know when to show UIRefreshControl.

Bellow is the whole solution that also handles the proper animation and simple pull to refresh animation.

Add to UITableView or subclass

Initialization:

 /// Refresh indicator
var refreshControl = UIRefreshControl()

/// Refresh state
var isRefreshing = false

/// Refresh controll update funcion. Set to enable pull to refresh
var refreshControllUpdateFunction: (() -> ())?

/// Prepeares UIRefreshControll. Call from init
func initRefreshControl(){
    addSubview(refreshControl)

    refreshControl.addTarget(self, action: "refreshControllTarget", forControlEvents: .ValueChanged)
    refreshControl.beginRefreshing()

    isRefreshing = true
}

Superview event handlers:

/// Call on viewWillApper
func superviewWillApper(){
    if isRefreshing && !refreshControl.refreshing{
        startRefreshAnimation()
    }
}

/// Call on viewDidDisapper
func superviewDidDisappear(){
    endRefreshAnimation(false, dataFetched: !isRefreshing)
}

UIRefreshControl animation handler:

/// Presents animating UIRefreshControll
func startRefreshAnimation(){
    refreshControl.beginRefreshing()
    contentOffset = CGPointMake(0, -refreshControl.bounds.size.height)

    isRefreshing = true
}

/// Hides UIRefreshControll and saves state of refresh
func endRefreshAnimation(wasEmpty: Bool, dataFetched: Bool){
    refreshControl.endRefreshing()

    isRefreshing = !dataFetched

    if !wasEmpty{
        setContentOffset(CGPointZero, animated: true)
    }else{
        setContentOffset(CGPointZero, animated: false)
    }
}

Add

table.isRefreshing = true

to begining of the refresh call.

Result video https://vid.me/LyuI

ios - UIRefreshControl Stuck After Switching Tabs in , I'm going to close this as wont fix. When returning to the controller while the sync is still in process, UIRefreshControl.refreshing is true , and  [ Natty] ios UIRefreshControl Stuck After Switching Tabs in UITabBarController By: Anton Kondrashov 1.5; [ Natty ] javascript TypeError: stepUp called on an object that does not implement interface HTMLInputElement By: Pankaj Rawat 4.0 ;

The following solution may help you.

CGFloat yTableViewOffset;

- (void)viewDidLoad {

      yTableViewOffset = kNilOptions;
}
- (void)viewWillAppear:(BOOL)animated
{
   if(yTableViewOffset != kNilOptions) {

     CGPoint offset = CGPointMake(tableView.contentOffset.x, yTableViewOffset);
     [refreshControl beginRefreshing];
     tableView.contentOffset = offset;

  }
}
- (void)viewWillDisappear:(BOOL)animated
{
   if(refreshControl.isRefreshing) {
     yTableViewOffset = tableView.contentOffset.y;
     [refreshControl endRefreshing];
  }
}

UIRefreshControl Stuck After Switching Tabs en UITabBarController , UIRefreshControl Stuck After Switching Tabs in UITabBarController. Question. I have a UITableViewController as the root view controller in a  Questions: “The app’s Info.plist can’t contain values for the UIRequiredDeviceCapabilities key that would prevent this app from opening on any iOS device. For more information, see Understanding the UIRequiredDeviceCapabilities Key.“

Simply calling endRefreshing in viewWillDisappear: fixed all the issues for me.

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.refreshControl endRefreshing];        
}

Doing the same thing in viewWillAppear: caused the refresh control to rotate strangely when pulling the table.

UIRefreshControl Stuck After Switching Tabs в UITabBarController, i have uitableviewcontroller root view controller in uinavigationcontroller, in turn 1 of view controllers in uitabbarcontroller. hooked in storyboard  UItabbarcontroller lazy switching tabs, only on simulator. 106 Views 0 Replies. Latest reply on Dec 21, 2017 7:58 AM by leandropetreca . Level 1 (0 points)

UIRefreshControl Stuck After Switching Tabs en UITabBarController - ios, iphone​, object-c, refresh, uirefreshcontrol. Tengo un UITableViewController como  The tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is, but may also be subclassed. Each tab of a tab bar controller interface is associated with a custom view controller.

Я знаю, что это невероятно поздно, но я думаю, лучше поздно, чем никогда. К сожалению, ни один из данных ответов не работал для меня. So my tab bar controller has two tabs which are both table views, and for each tab I have a navigation stack as the root view controller. So the order of controllers for each of the two tabs goes as follows: tab bar controller, navigation controller, table view controller and the hierarchy tab at index 0 passes a mutable array to the tab at index 1

Issue is, each tab has a number of nested UIViewControllers (Search, Detail, Wizard, etc) When one progress to the second or third view controller in the stack and they switch to a different tab but when they return back to the original tab, it resumes it's position on the second or third controller rather than the starting one.

Comments
  • May be it is a bug in ios itself?
  • Too many solutions that not working.
  • Great Answer! I still see this issue in iOS 9. This need to be solved by Apple in their next release.
  • Same for me. I see it now in my app. iOS 10.2 (14C89).
  • Stil the only proper solution for iOS 12.2. For those considering simply calling "endRefreshing" upon viewDidAppear or other, change tabs/views fairly quickly and that is why those solutions do not work.
  • view will disappear doesn't get called when we put application in background and in this case loader gets stuck