RichieSwiperDataSource

Objective-C

@protocol RichieSwiperDataSource <NSObject>

/**
 If the number of pages in Swiper changes, call -reloadData to let the know that.
 */
-(NSInteger) numberOfPagesInSwiper:(id<RichieSwiper>)swiper;

/**
 DataSource is responsible for creating views for pages.
 It can use -[RichieSwiper frameForPageAtIndex:] for creating the view with correct size.
 RichieSwiper itself doesn't use auto layout, but pages can use auto layout internally.
 Note that the returned view will have it's frame set so it's as wide as the swiper view,
 and centered vertically if it's shorter than swiper view.
 */
-(UIView *) swiper:(id<RichieSwiper>)swiper pageAtIndex:(NSInteger)pageIndex;


@optional

/**
 Called after RichieSwiper has removed page view from view hierarchy.
 This is an opportunity for the DataSource to do any necessary tear down (clearing delegates, stopping operations)
 if page view instances aren't recycled or otherwise cached. Also, this method can be used to gather views for
 recycling (manually), similar to how UITableView recycles cell views.
 Views cached for recycling in this call can be later returned by -swiper:pageAtIndex:.
 */
-(void) swiper:(id<RichieSwiper>)swiper didRemovePage:(UIView *)view atIndex:(NSInteger)pageIndex;

@end

Swift

protocol RichieSwiperDataSource : NSObjectProtocol

Undocumented

  • If the number of pages in Swiper changes, call -reloadData to let the know that.

    Declaration

    Objective-C

    - (NSInteger)numberOfPagesInSwiper:(id<RichieSwiper>)swiper;

    Swift

    func numberOfPages(in swiper: (any RichieSwiper)!) -> Int
  • DataSource is responsible for creating views for pages. It can use -[RichieSwiper frameForPageAtIndex:] for creating the view with correct size. RichieSwiper itself doesn’t use auto layout, but pages can use auto layout internally. Note that the returned view will have it’s frame set so it’s as wide as the swiper view, and centered vertically if it’s shorter than swiper view.

    Declaration

    Objective-C

    - (UIView *)swiper:(id<RichieSwiper>)swiper pageAtIndex:(NSInteger)pageIndex;

    Swift

    func swiper(_ swiper: (any RichieSwiper)!, pageAt pageIndex: Int) -> UIView!
  • Called after RichieSwiper has removed page view from view hierarchy. This is an opportunity for the DataSource to do any necessary tear down (clearing delegates, stopping operations) if page view instances aren’t recycled or otherwise cached. Also, this method can be used to gather views for recycling (manually), similar to how UITableView recycles cell views. Views cached for recycling in this call can be later returned by -swiper:pageAtIndex:.

    Declaration

    Objective-C

    - (void)swiper:(id<RichieSwiper>)swiper
        didRemovePage:(UIView *)view
              atIndex:(NSInteger)pageIndex;

    Swift

    optional func swiper(_ swiper: (any RichieSwiper)!, didRemovePage view: UIView!, at pageIndex: Int)