gpt4 book ai didi

ios - iCarousel 问题

转载 作者:行者123 更新时间:2023-11-28 22:40:21 24 4
gpt4 key购买 nike

我正在尝试使用以下代码将 iCarousel 添加到现有项目,但出现此错误:MemberCatalog[14990:1a903] -[MainViewController carousel:viewForItemAtIndex:reusingView:]: unrecognized selector发送到实例 0xa0589b0。

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: 方法,但 View 需要 -carousel:viewForItemAtIndex:reusingView: 方法。

您需要使用 reusingView:(UIView *)view 参数更新您的方法,这样就没问题了。您还应该使用该可重用 View ,而不是分配越来越多的 View ,但那是另一回事了。

关于ios - iCarousel 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14710791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com