Disable vertical scroll in UIScrollView Swift
very charm solution is:
// also don't forget
// YourViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
self.scrollView.delegate = self
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y > 0 || scrollView.contentOffset.y < 0 {
scrollView.contentOffset.y = 0
}
}
You can simply do this. Swift 4
self.scrollView.contentSize.height = 1.0 // disable vertical scroll