0
我想一個iCarousel添加到下面的代碼現有的項目,但我得到這個錯誤:MemberCatalog[14990:1a903] -[MainViewController carousel:viewForItemAtIndex:reusingView:]: unrecognized selector sent to instance 0xa0589b0.
iCarousel問題
在iCarousel.m引發錯誤的行是:view = [_dataSource carousel:self viewForItemAtIndex:index reusingView:[self dequeueItemView]];
任何幫助它會真的很感激它。
carouselItems = [NSArray arrayWithObjects:
[UIImage imageNamed:@"iLibrary+Featured_AM-RAH.png"],
[UIImage imageNamed:@"iLibrary+Featured_CCA.png"],
[UIImage imageNamed:@"iLibrary+Featured_GI-PA.png"],
nil];
// Initialize and configure the carousel
carousel = [[iCarousel alloc] initWithFrame:self.view.bounds];
carousel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
carousel.type = iCarouselTypeCoverFlow2;
carousel.delegate = self;
carousel.dataSource = self;
[self.view addSubview:carousel];
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
UIImage *image = [carouselItems 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.tag=index;
return button;
}
你執行'-carousel:viewForItemAtIndex:reusingView:'在所有? –
是的。我做了: - (UIView *)旋轉木馬:(iCarousel *)旋轉木馬viewForItemAtIndex:(NSUInteger)索引 { \t UIImage * image = [carouselItems objectAtIndex:index]; \t的UIButton *按鈕= [[[UIButton的頁頭] initWithFrame:方法CGRectMake(0,0,image.size.width,image.size.height)]自動釋放]; \t [按鈕了setBackgroundImage:圖像forState:UIControlStateNormal]; \t [按鈕setTitleColor:的UIColor blackColor] forState:UIControlStateNormal]; \t button.titleLabel.font = [button.titleLabel.font fontWithSize:50]; \t button.tag = index; \t return button; \t } –
嗯,這方法顯然是缺少'reusingView:'部分 –