Gaurang Makwana
Gaurang Makwana

Reputation: 216

Disable only vertical scrolling of UIScrollView inside UITableViewCell

I have scrollView inside my custom UITableViewCell. Now I want to disable the only vertical scrolling of scrollView inside the Custom UITableViewCell, So I can detect the vertical scrolling of its parentView UITableView during its vertical scrolling.

Note: However custom cell should have horizontal scrolling every time.

Thanks in Advance.

Upvotes: 0

Views: 1145

Answers (2)

J. Lopes
J. Lopes

Reputation: 1345

Either you can try this:

self.tableView.alwaysBounceVertical = NO;

Or you can try set the contentSize, like:

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

I hope this can help you.

Upvotes: 2

KrishnaCA
KrishnaCA

Reputation: 5695

For UIScrollView, scrolling depends on the contentSize property. So, if you set the vertical content size to the frame of your scrollview. It should work.

let ContentSize_X: CGFloat = 1000 // set this to your contentsize in horizontal direction

let scrollView: UIScrollView = UIScrollView(frame: scrollFrame)
scrollview.contentSize = CGSizeMake(ContentSize_X, scrollView.frame.size.height)

Upvotes: 0

Related Questions