Search code examples
cocoaswiftnsscrollview

How can I disable horizontal scrolling for an NSScrollView?


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?


Solution

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

    Fixes the frame width to prevent horizontal scrolling.