1

I have a UITableViewController. I have enabled the 'refreshing' property in attribute inspector. In viewDidLoad I have assigned a selector (i.e. pull to refresh action). In the pull to refresh action, as the last step, I invoke refreshControl.endRefreshing()

After refresh action, table returns to its original position on any device using iOS < v10. Prior to iOS 10 it worked without an issue.

Still using Swift 2.2.

Additional info: The Pull to Refresh triggers a check if data download is needed. If not, it raise an alert, that only has an "OK" action to dismiss the alert. The alert is managed using:

self.presentViewController(alert, animated: true, completion: nil)

Could it be that because the table does not return to its original place before the alert is triggered, it get stuck in the last know position?

If so, is there away to ensure the table goes back to its original position without having to call refreshControl.endRefreshing() just before the alert appears?

Thoughts?

zevij
  • 2,416
  • 1
  • 23
  • 32

1 Answers1

1

Based on this answer (and although I am using UITableViewController and not a ViewController + Table) I have done the following:

  1. in viewDidLoad store the tableView.contentOffset as initialContentOffset (note that this is a CGPoint variable)
  2. after pull to refresh, set tableView.contentOffset = initialContentOffset

Other issues:

  1. the initial content offset of the table seems to be (0, 0). As I have a navigation bar, I calculated the y-offset (which comes out at 66). I then create my initialContentOffset as CGPoint(0, -66)
  2. In my case, this issue seem to only impact iPhone 6sp on ios 10. Don't know why...
Community
  • 1
  • 1
zevij
  • 2,416
  • 1
  • 23
  • 32