DroidsOnRoids / SwiftCarousel

Lightweight, written natively in Swift, circular UIScrollView.

Home Page:http://www.thedroidsonroids.com/blog/ios/circular-scroll-view-swiftcarousel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong item selected

frranck opened this issue · comments

I have this weird behaviour: the selected item returns the item to the left, and not the one in the middle of the screen. I'm using .resizeType = .FloatWithSpacing(10.0) and 1 item per screen.
Anyone noticed this ?

I don't observe that on the puppy selector though..

Found a "hack" to go around that problem by using .tag of UIView as index... Still now clue where it's coming from.

commented

Is that behavior in our examples as well?

No it's not, and I couldn't figure out what difference makes it bug in my code.

commented

Could you try to reproduce the bug using the settings of a carousel you have in your project? Maybe that way we can try to find the issue. For now I'm ¯_(ツ)_/¯

Ok I figured out: the problem is that I create the carousel with:

carousel = SwiftCarousel(frame: carouselFrame, items: [UIView()])

and then I set the corrects views.
If I create it with

carousel = SwiftCarousel(frame: carouselFrame)

I don't have this problem.

commented

Perfect! Yeah, you don't need to specify your items in init, you can do it later. Thanks for resolving the issue! 🎉