bhzag
bhzag

Reputation: 2980

Disabling vertical scrolling in UIScrollView in swift?

So I have my UIScrollView,

    var myScrollView = UIScrollView(frame:theFrame)

and I would like to disable vertical scrolling. Does anyone know how to implement this using Swift?

Upvotes: 10

Views: 17289

Answers (2)

JSNoob
JSNoob

Reputation: 1577

Another way to do this is to set the height to 1.0

scrollView.contentSize = CGSizeMake(theFrame.size.height, 1.0)

Upvotes: 15

Milo
Milo

Reputation: 5091

Try this. This sets the content size to the height of the frame so it disables vertical scrolling because it can display the whole size.

let scrollSize = CGSizeMake(theFrame.size.height, yourWidth)
myScrollView.contentSize = scrollSize

Upvotes: 6

Related Questions