When reading the Quran using the app on an iPad Pro in landscape and reaching the end of the page, the flip to next page causes the page to start at the bottom.
It is difficult to say where the logic is broken without looking at the code, but I think a good place to start will be page layout. Let me share an example.
Example with incorrect calculation: import UIKit
class ViewController: UIViewController {
// Assuming you have a scrollView and an array of page views
@IBOutlet weak var scrollView: UIScrollView!
var pageViews: [UIView] = []
override func viewDidLoad() {
super.viewDidLoad()
// Add your page views to the scrollView
for i in 0..<numberOfPages {
let pageView = UIView(frame: CGRect(x: CGFloat(i) * scrollView.bounds.width,
y: 0,
width: scrollView.bounds.width,
height: scrollView.bounds.height))
pageViews.append(pageView)
scrollView.addSubview(pageView)
}
// Set up paging in the scrollView
scrollView.isPagingEnabled = true
scrollView.contentSize = CGSize(width: CGFloat(numberOfPages) * scrollView.bounds.width,
height: scrollView.bounds.height)
}
func flipToNextPage() {
let currentPage = Int(scrollView.contentOffset.x / scrollView.bounds.width)
let nextPage = currentPage + 1
if nextPage < pageViews.count {
// Incorrect calculation causing the next page to appear at the bottom
let newYOffset = scrollView.contentOffset.y + scrollView.bounds.height
scrollView.setContentOffset(CGPoint(x: CGFloat(nextPage) * scrollView.bounds.width,
y: newYOffset),
animated: true)
}
}
}
In the above example, the flipToNextPage function is meant to flip to the next page horizontally and continue from the top. However, the incorrect calculation of newYOffset causes the new page to appear at the bottom instead.
Example with correct page layout calculation:
func flipToNextPage() {
let currentPage = Int(scrollView.contentOffset.x / scrollView.bounds.width)
let nextPage = currentPage + 1
if nextPage < pageViews.count {
// Corrected calculation to reset vertical offset to 0
scrollView.setContentOffset(CGPoint(x: CGFloat(nextPage) * scrollView.bounds.width,
y: 0),
animated: true)
}
}