DroidsOnRoids / SwiftCarousel

Lightweight, written natively in Swift, circular UIScrollView.
http://www.thedroidsonroids.com/blog/ios/circular-scroll-view-swiftcarousel/
MIT License
144 stars 43 forks source link

Wrong item selected #26

Closed frranck closed 8 years ago

frranck commented 8 years ago

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 ?

frranck commented 8 years ago

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

frranck commented 8 years ago

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

sunshinejr commented 8 years ago

Is that behavior in our examples as well?

frranck commented 8 years ago

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

sunshinejr commented 8 years ago

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 ¯(ツ)

frranck commented 8 years ago

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.

sunshinejr commented 8 years ago

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