Search code examples
objective-ciosicarousel

How to select only center image of iCarousel?


I have a iCarousel gallery in which I am getting images from web service. The gallery showing perfectly. I used iCarasouel delegate method "didSelectItemAtIndex" for selecting the First to last image. My icarousel type is "carousel.type = iCarouselTypeCoverFlow;".

I selected the image and i got proper index of image, didSelectItemAtIndex works properly only when I scroll gallery and image is moved from center, but when the view is load "Frist or any images" are showing in center are not selected by didSelectItemAtIndex. when I scroll the gallery again and center image is moved from the center then its works fine, then I am able to select the image and go to the next Class or view.

I want to select image which are showing in the center of Icaraosel. Don't know how to do it?

Any hints from experts would be very welcome.


Solution

  • You can get the current index of the image in the given below delegate method

    - (void)carouselCurrentItemIndexUpdated:(iCarousel *)carousel1
    

    Once your images load s completely then call

    [self carouselCurrentItemIndexUpdated:carousel];
    

    Here is the code :

    In your viewDidLoad call the method as shown below,here carsousel is in an instance of iCarsouel.

    - (void)viewDidLoad
    {
       [super viewDidLoad];
       [self carouselCurrentItemIndexUpdated:carousel];
    }
    
    
      - (void)carouselCurrentItemIndexUpdated:(iCarousel *)carousel1
    {
       self.currentItem=carousel1.currentItemIndex;
       NSLog(@"currentItem update== %i",self.currentItem);
    }
    

    Hope this helps....