0

Is it possible to detect when the user has exhausted through all the feed in their TableViewController?

If so, how?

For example, when you swipe down, all the way to the first post, you should get an error message that says, "You're up to date".

dooooooo
  • 3
  • 2
  • I don’t believe there are any delegate methods for this so it’s not a simple solution. – Mike Aug 28 '19 at 03:51
  • this will help i think https://stackoverflow.com/questions/7706152/iphone-knowing-if-a-uiscrollview-reached-the-top-or-bottom, since table inherits scroll properties – Bista Aug 28 '19 at 04:28

1 Answers1

1

You can add refresh control in the tableView and check that the data is updated or not in refresh control method. if no new record found then you show You're up to date.

Ex.

var refreshControl = UIRefreshControl()

override func viewDidLoad() {
   super.viewDidLoad()

   refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
   refreshControl.addTarget(self, action: #selector(refresh(_:)), for: UIControl.Event.valueChanged)
   tableView.addSubview(refreshControl) // not required when using UITableViewController
}

@objc func refresh(sender:AnyObject) {
   // Code to refresh table view  
   // Check data is updated or not and the show alert from here
}
Nilesh R Patel
  • 697
  • 7
  • 17