Skip to content

jbrayton/ipad-scroll-position-fix

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

iPad Scroll Position Fix

Radar 37650722 describes the following bug (as of iOS 11.2.6):

  1. Create an app with a simple UITableView with enough rows to require scrolling. (I use UITableView as an easy example, but this happens with any UIScrollView.)
  2. Run that app on an iPad.
  3. Put the iPad in landscape orientation.
  4. Scroll to the bottom of the table.
  5. Press the home button to leave the app.
  6. Open the app again.

Expected Results: I would expect the table view to remain scrolled to the bottom.

Actual Results: The table view is no longer scrolled to the bottom.

This project demonstrates the issue. It also includes the code I used to address this in Unread.

To incorporate the fix in your app, do the following:

  1. Copy GHSScrollPositionFix.swift into your project.

  2. Add a GHSScrollPositionFix to your view controller.

var scrollPositionFix: GHSScrollPositionFix?
  1. In your viewDidLoad method, create the scroll position fix:
self.scrollPositionFix = GHSScrollPositionFix(scrollView: self.tableView)
  1. Call the viewWillTransition method of scrollPositionFix from the viewWillTransition method of the view controller:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    self.scrollPositionFix?.viewWillTransition(to: size, with: coordinator)
}

The code can be used from Swift or from Objective-C.

Pull requests welcome.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages