Disable Vertical Scroll in Uiscrollview Swift

Disable vertical scroll in UIScrollView Swift

Since iOS 11 content insets can get adjusted automatically. Try setting your scrollview's behaviour to not adjust it.

if #available(iOS 11, *) {
scrollview.contentInsetAdjustmentBehavior = .never
}

Disabling Horizontal Scrolling from UIScrollView Swift

Like this,

Swift 4.0

func scrollViewDidScroll(scrollView: UIScrollView) {
if scrollView.contentOffset.x>0 {
scrollView.contentOffset.x = 0
}
}

And, you can set this property:

scrollImg.isDirectionalLockEnabled = true

Disabling vertical scrolling in UIScrollView in swift?

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

Disabling vertical scrolling in UIScrollView

Try setting the contentSize's height to the scrollView's height. Then the vertical scroll should be disabled because there would be nothing to scroll vertically.

scrollView.contentSize = CGSizeMake(scrollView.contentSize.width,scrollView.frame.size.height);

How to disable vertical scrolling in UIScrollView (Obj-C)

you must set your scrollview content height to the scroll view height


CGSize scrollableSize = CGSizeMake(scrollableWidth, yourScrollViewHeight);
[myScrollView setContentSize:scrollableSize];



Related Topics



Leave a reply



Submit