How can I disable horizontal scrolling for NSScrollView?

I first tried disabling the scrollbar by setting:

scrollView!.hasHorizontalScroller = false

      

and it worked successfully, but I could still scroll from left to right using my trackpad. Is there a way to ensure that horizontal scrolling is completely disabled for the NSScrollView object?

+3


source to share


2 answers


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

      



Sets the width of the border to prevent horizontal scrolling.

+1


source


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



scrollView.horizontalScrollElasticity = .None

      

0


source







All Articles