简体   繁体   English

iCarousel在自定义TableView单元中不起作用

[英]iCarousel is not working in custom TableView Cell

First of All Thanks for the iCarousel. 首先感谢您的iCarousel。 I am trying the iCarousel in custom TableView Cell, but it crashes by saying "Unrecognized selector sent in numberOfItemsInCarousel". 我在自定义TableView单元中尝试使用iCarousel,但由于说“在numberOfItemsInCarousel中发送了无法识别的选择器”而崩溃。 Please help me on this. 请帮我。 Thanks in advance..! 提前致谢..!

-(nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    TimelineCell *cell = (TimelineCell *)[tableView dequeueReusableCellWithIdentifier:@"timelineCell"];
    if (cell == nil) {
        NSArray *cellItem = [[NSBundle mainBundle]loadNibNamed:@"TimelineCell" owner:self options:nil];
        cell = [cellItem firstObject];
    }
    cell.images = imageArray;
    return cell;
}

- (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
    [carousel setType:iCarouselTypeTimeMachine];
    return [_images count];
}

Sounds like the delegate for the iCarousel is set to something else than the class implementing the method numberOfItemsInCarousel:(… . 听起来好像iCarousel的委托设置为除实现numberOfItemsInCarousel:(…的方法的类之外的其他东西。

Make sure you've set the delegate to the correct instance. 确保已将委托设置为正确的实例。

You probably want the TimelineCell to be the carousel delegate, so make sure that you do set it (either in your xib-file or programatically). 您可能希望TimelineCell是轮播代理,因此请确保您确实进行了设置(在xib文件中或以编程方式)。 Put the numberOfItemsInCarousel(… -method implementation in the TimelineCell class and it should work. numberOfItemsInCarousel(… -method实现放在TimelineCell类中,它应该可以工作。

Another tip is to not set the carousel type in the method numberOfItemsInCarousel(… . Not a pretty place for it. Instead do it in some initialisation method. 另一个提示是不要在numberOfItemsInCarousel(…方法中设置轮播类型,这不是一个不错的选择,而是在某种初始化方法中进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM