0
由於某些原因,當我設置iCarousel.type = iCarouselTypeLinear
時,我無法使用超過6張圖片。當我嘗試滾動時,出現以下錯誤: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;
}
您可以發佈控制器代碼,以便我們可以看到代碼中可能出現錯誤嗎?現在我們只是有一個錯誤,沒有代碼看,這是沒有用的。 – Walls
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]; –