I have a UIScrollView with a UIView inside. I want to lock the x-axis so that the view is only scrolled vertically. How do I enable directional locking?
I have a UIScrollView with a UIView inside. I want to lock the x-axis
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, set the
UIScrollView‘scontentSizeto have a width that is equal to or less than the width of the UIScrollView’s frame.Next, set
UIScrollView'salwaysBounceHorizontalto NO. This will prevent the scroll view from “rubber banding” even though you’ve told it there’s no more horizontal content to display.It doesn’t matter what’s actually inside the scroll view.
Swift 5.0