nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12.01k stars 2.58k forks source link

How can I use view controllers in iCarousel #628

Closed serhatsezer closed 5 years ago

serhatsezer commented 9 years ago

I want to use different type of view controllers like CollectionViewController and UITableViewController as well as I want to use Controller's delegate methods like viewWillAppear: and viewDidLoad: how can I achive this ?

Simply i'm creating view controllers instance and adding their view to "(CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value" delegation method. But their possition are not appropiate.

nicklockwood commented 9 years ago

Just create UICollectionViews and UITableViews - you don't need a controller for each view.

serhatsezer commented 9 years ago

Hi @nicklockwood , Thank you for quick response. But i can't get it. I simply want to create two separate carousel where are placed top and bottom. Top carousel view indicate "which view controller now showed" and bottom carousel show collection view controller.

Like this framework ; https://github.com/uacaps/PageMenu

and here is my gist; https://gist.github.com/serhatsezer/0d5200b18d61310d62dc

Thank you so much.

serhatsezer commented 9 years ago

@nicklockwood OK, finally i've find a solution :) still i'm using controllers and I added that controller as a child of current view controller return their views. So i'm using their class methods and own implementations.

https://gist.github.com/serhatsezer/77b44e96f84ec0689202

mbcoder17 commented 9 years ago

Were you able to get this working as a menu? With one carousel controlling another?

serhatsezer commented 9 years ago

@mbcoder17 Yes you can be able to do this by using delegate method. Let say you have two separate iCarousel object and their names are "headerCarousel" and "contentCarousel";

- (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel  {

    NSInteger currentItemIndex = carousel.currentItemIndex;

    if(carousel == self.headerCarousel) {
         [self.contentCarousel scrollToItemAtIndex:currentItemIndex animated:YES];
    }
    else if(carousel == self.contentCarousel) {
        [self.headerCarousel scrollToItemAtIndex:currentItemIndex duration:0.8];
    }
}
mbcoder17 commented 9 years ago

Thanks, but I think Nick's answer from a different issue will work better:

"Yes, you can sync them perfectly. In the carouselDidScroll delegate event of one carousel set the scrollOffset of the other carousel to match the first one (the scrollOffset is now readwrite and public)"

On Jul 16, 2015, at 4:33 PM, Serhat Sezer notifications@github.com wrote:

@mbcoder17 Yes you can. Let say you have two separate iCarousel object and their names are "headerCarousel" and "contentCarousel";

(void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel {

NSInteger currentItemIndex = carousel.currentItemIndex;

if(carousel == self.headerCarousel) { [self.contentCarousel scrollToItemAtIndex:currentItemIndex animated:YES]; } else if(carousel == self.contentCarousel) { [self.headerCarousel scrollToItemAtIndex:currentItemIndex duration:0.8]; } }

— Reply to this email directly or view it on GitHub.