Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable just vertical scrolling in a UIScrollView?

Tags:

UIScrollView has a property scrollEnabled to disable all scrolling, but I want to disable only the vertical scrolling.

Is that possible? Thanks.

like image 739
Wooly Avatar asked Sep 23 '11 21:09

Wooly


People also ask

How do I stop vertical scrolling?

To hide the vertical scrollbar and prevent vertical scrolling, use overflow-y: hidden like so: HTML.

How do I disable scrolling in Swiftui?

We will use SimultaneousGesture and DragGesture to disable scrolling. We will set DragGesture's minimum distance to 0, which will disable the drag gesture to stop the scroll behavior.

How do I enable horizontal scrolling in ScrollView?

In android, ScrollView supports only vertical scrolling. In case, if we want to implement horizontal scrolling, then we need to use a HorizontalScrollView component.


1 Answers

If the scrollView's contentSize.height is less than its bounds.size.height it won't scroll vertically.

Try setting:

scrollView.contentSize = (CGSize){<yourContentWidth>, 1.0}


Swift

scrollView.contentSize = CGSize(width: <yourContentWidth>, height: 1.0)

like image 149
Ashley Mills Avatar answered Sep 21 '22 23:09

Ashley Mills