c# - Linear Carousel with wrap enabled -
i want make carousel that's linear wrap enabled (so can scroll indefinitely in either direction , it'll wrap around) have carouseltype.linear, isn't wrap enabled. know of how either icarousel or uicollectionviews? can't find resources on how make custom icarousel layout... references there?
this.carousel = new carouselview(frame) { datasource = new cylindericaldatasource(this), delegate = new cylindericaldelegate(this) }; this.carousel.carouseltype = carouseltype.linear; this.carousel.configureview(); this.view.addsubview(this.carousel);
------------edit--------------
to answer @rahul's question
public override void didscroll (carouselview carouselview) { base.didscroll (carouselview); nint numofitems = carouselview.numberofitems; if (this._parentcontroller != null && this._parentcontroller._studioviewcontroller != null && this._parentcontroller._studioviewcontroller.successfullyreceivedprojectandpagedata () && this._parentcontroller._studioviewcontroller.hasflowcardcarouselfinishedloading () && numofitems > 0) { // enforce min , max values fro scrolloffset user can't scroll carousel off screen. required when wrapping turned off. nfloat maxscrolloffset = ((nfloat)numofitems) - 1f; nfloat minscrolloffset = 0f; if (carouselview.scrolloffset < minscrolloffset) { carouselview.scrolloffset = minscrolloffset; } if (carouselview.scrolloffset > maxscrolloffset) { carouselview.scrolloffset = maxscrolloffset; } } }
figured out. override valueforoption method , force carouseoption.wrap equal 1.0f. see below
/*--------------------------------------------------------------------------------*/ // class: cylindericaldelegate /*--------------------------------------------------------------------------------*/ public class cylindericaldelegate : carouselviewdelegate { /*--------------------------------------------------------------------------------*/ // constructors /*--------------------------------------------------------------------------------*/ public cylindericaldelegate() { } /*--------------------------------------------------------------------------------*/ // cylindericaldelegate implementation /*--------------------------------------------------------------------------------*/ public override nfloat valueforoption(carouselview carousel, carouseloption option, nfloat avalue) { if (option == carouseloption.spacing) { return avalue * 1.1f; } if (option == carouseloption.wrap) { return 1.0f; } return avalue; } /*--------------------------------------------------------------------------------*/ } /*--------------------------------------------------------------------------------*/
Comments
Post a Comment