なんらかの理由で設定した場合iCarousel.type = iCarouselTypeLinear
、6枚以上の画像は使用できません。スクロールしようとすると、次のエラーが発生します。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0xa47c2b0'
私は何が欠けていますか?
どんな助けでも本当にありがたいです。
コントローラーコード:
journalCarouselItems = [NSMutableArray arrayWithObjects:
[UIImage imageNamed:@"Icon-JCO1.png"],
[UIImage imageNamed:@"Icon-JCO2.png"],
[UIImage imageNamed:@"Icon-JCO3.png"],
[UIImage imageNamed:@"Icon-JCO4.png"],
[UIImage imageNamed:@"Icon-JCO5.png"],
[UIImage imageNamed:@"Icon-JCO6.png"],
[UIImage imageNamed:@"Icon-JCO7.png"],
[UIImage imageNamed:@"Icon-JCO8.png"],
[UIImage imageNamed:@"Icon-JCO9.png"],
[UIImage imageNamed:@"Icon-JCO10.png"],
[UIImage imageNamed:@"Icon-JCO11.png"],
nil];
// Initialize and configure the carousel
carouselId = 2;
journalCarousel = [[iCarousel alloc] initWithFrame: CGRectMake ( 10, 340, 748, 240)];
journalCarousel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
journalCarousel.type = iCarouselTypeLinear;
journalCarousel.delegate = self;
journalCarousel.dataSource = self;
[self.view addSubview:journalCarousel];
編集:デバッグ中に、6つの画像がある場合は毎回以下の関数が呼び出され、インデックス値が0から5になりますが、6つを超える画像がある場合、各画像に対して同じ関数が呼び出されないことに気付きました。インデックス値0、2、8、9です。
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(ReflectionView *)view
{
UIImage *image = [journalCarouselItems objectAtIndex:index];
UIButton *button = [[[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)] autorelease];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [button.titleLabel.font fontWithSize:50];
button.layer.cornerRadius = 8.0f;
button.tag=index;
[view addSubview:button];
return view;
}