问题描述:

I first tried disabled the scroll bar by setting:

scrollView!.hasHorizontalScroller = false

and that successfully worked, but I could still scroll from left to right by using my trackpad.

Is there a way to ensure that horizontal scrolling is completely disabled for an NSScrollView object?

网友答案:
var scrollView = UIScrollView(frame:myFrame)
let scroll = CGSizeMake(myHeight, myFrame.size.width)
scrollView.contentSize = scroll

Fixes the frame width to prevent horizontal scrolling.

网友答案:

Even with a correct content size, I was still able to use two-finger gestures to scroll horizontally a bit before it snaps back into place. To fix this, you can set the elasticity:

scrollView.horizontalScrollElasticity = .None
相关阅读:
Top