nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS

Home Page:http://www.charcoaldesign.co.uk/source/cocoa#icarousel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to scroll horizontally when a user scrolls the a tableview

EddieMa opened this issue · comments

commented

Hi everyone,

I am using this amazing class to build a card view. But I have one issue which is how to achieve vertical scroll when it is a horizontal model when it is in a tableview cell and the user scrolls down/up the tableview. In other word, I want to implement users scroll down/up the tableview, the iCarousel also be scrolled horizontally.

Thanks in advance
Eddie

The best bet is probably to set the carousel.scrollOffset property programmatically from inside your UITableViewDelegate’s scrollViewDidScroll method.

commented

@nicklockwood , thank you for your reply, could you please give me more hints about how to set customized scrollOffset?

(In swift)

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    carousel.scrollOffset.x = scrollView.contentOffset.y / carousel.itemWidth
}

You may need to multiply the scrollView offset by some constant to get the exact effect you want.