How to select only the center image of iCarousel?

I have an iCarousel gallery where I receive images from a web service. The gallery is showing great. I used the iCarasouel delegation method "didSelectItemAtIndex" to select the image from the first to the last. My icarousel type is "carousel.type = iCarouselTypeCoverFlow;".

I selected the image and I got the correct image index. didSelectItemAtIndex only works correctly when I scroll through the gallery and the image moves from the center, but when the image is loaded, "Frist or any images" appear in the center, didSelectItemAtIndex is not selected. when I scroll through the gallery again and the central image moves from the center, then it works fine, then I can select the image and go to the next class or view.

I want to select an image that is displayed in the center of Ikaraosel. Not sure how to do this?

Any tips from experts would be very welcome.

+4
source share
3 answers

You can get the current image index in the delegate method below

- (void)carouselCurrentItemIndexUpdated:(iCarousel *)carousel1 

Once your images have fully loaded, call

 [self carouselCurrentItemIndexUpdated:carousel]; 

Here is the code:

In your DidLoad view, call the method as shown below, here carousel is in the iCarsouel instance.

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

Hope this helps ...

+3
source

I don’t know if I understood you correctly: you want to receive the message didSelectItemAtIndex: immediately after the initial reload of the view and without scrolling?

just ask currentItemIndex , and if you want the selected center to always call centerItemWhenSelected

so just call [self didSelectItemAtIndex: carousel.currentItemIndex]; `manually

+1
source
 -(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index { if (index == carousel.currentItemIndex) { ///Selected centered item only } } 
+1
source

All Articles