Search code examples
ipadios6icarousel

iCarousel item index change does not sync with their random details shown in the UITextView


I am using iOS6 and in my iPad application where I have a requirement to show a carousel of views and details of the selected carousel item in textView below it. Users can select the carousel view either by clicking it or by scrolling. When the scrolling ends the details in the textView should show the details based on the carousel item selected (description, summary etc). I am able to update the index and there by the textviews.

I'm using - (void)carouselDidEndScrollingAnimation:(iCarousel )carousel method to know when the scrolling animation is stopped. This method is triggered when scrolling is stopped either programmatically or user driven.

- (void)carouselDidEndScrollingAnimation:(iCarousel *)carousel
{
    [self setSelectedItemIndex:[carousel currentItemIndex]];
}

From the index I fetch the corresponding details and reload the views. I have modified the setter method to reload the details. The index gets assigned only when the delegate is triggered.

Till this point everything is working fine. I'm able to show values corresponding to each item. Every item don't always have valid values. But when the user keeps on dragging the carousel though there is no trigger to change the value of textView keeps on changing. Once the scrolling stops and the above delegate is triggered the correct value is shown.

*Only a change of value in selectedItemIndex should trigger a change in the value of textView. But while scrolling some bogus values are shown in one textView.

- (void)setSelectedMemoIndex:(NSUInteger)selectedMemoIndex
  {
  _selectedMemoIndex = selectedMemoIndex;
  [self didSelectItemAtIndex:_selectedMemoIndex];
  }

How value is assigned to textView

- (void)didSelectItemAtIndex:(NSInteger)index 
   {   //items array is a collection of NSManagedObjects  
   Item *item = self.items[index];  
   self.summaryTextView.text = item.summary;  
   self.descTextView.text = item.desc;  
   }

Any help would be highly appreciated


Solution

  • From the comments

    The code looks good.The problem may be somewhere in code you may be setting the value in the textview.Probably in some delegate method since it is changing when the scroll is done.