Chapter 44 - Landscape

I’m trying to customize a scroll view for a horizontal view for iPhone 11. I want to have the right side rectangles further away from the top-notch which I have done. The problem is that if I do a hard scroll to the left, it keeps bouncing back a little off of the original position.

When the view loads:
Screen Shot 2020-03-28 at 1.35.11 AM

After I do the hard scroll to the left:
Screen Shot 2020-03-28 at 1.37.47 AM

Here is my code that I think all you need to see

override func viewWillLayoutSubviews() {
   let safeFrame = view.safeAreaLayoutGuide.layoutFrame
   scrollView.frame = safeFrame
}

   func setButtons(searchResults: [SearchResults] {
        case 724:
            //iPhone X, iPhone 11 Pro
            columnsPerPage = 8
            rowsPerPage = 3
            itemWidth = 90
            itemHeight = 98
            marginX = 2
            marginY = 29
            scrollView.frame.origin.x = 25
            scrollView.contentOffset.x = 19
   }
     
   let buttonsPerPAge = columnsPerPage * rowsPerPage
   let numPages = 1 + (searchResults.count - 1) / buttonsPerPAge
   scrollView.contentSize = CGSize(width: CGFloat(numPages) * viewWidth, height: scrollView.bounds.size.height)

@mcneils Do you still have issues with this?

This topic was automatically closed after 166 days. New replies are no longer allowed.