屏幕转换期间 iCarousel Sticks

Posted

技术标签:

【中文标题】屏幕转换期间 iCarousel Sticks【英文标题】:iCarousel Sticks during screen transition 【发布时间】:2013-12-03 08:07:35 【问题描述】:

我正在使用 iCarousel。轮播包含大约 10 张图像。在屏幕转换时,图像会卡在下一个屏幕上。我在返回原始屏幕时使用popToRootview。它与UIImage alloc 有关吗?

我的代码:

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel

    return ([animals count]);


- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel

    //limit the number of items views loaded concurrently (for performance reasons)
    return 7;


- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index

    NSString *filePath1 = [animals objectAtIndex:index];    
    UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath1];

    //create a numbered view
    UIView *view = [[UIImageView alloc] initWithImage:image];
    view.frame  = CGRectMake(0.0f, 0.0f, 230, 150);
    return view;


- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel

    //note: placeholder views are only displayed on some carousels if wrapping is disabled
    return 0;


- (CGFloat)carouselItemWidth:(iCarousel *)carousel

    //usually this should be slightly wider than the item views
    return 240;


- (BOOL)carouselShouldWrap:(iCarousel *)carousel

    //wrap all carousels
    return wrap;


- (void)carouselDidEndScrollingAnimation:(iCarousel *)aCarousel

    label.text =  [descriptions objectAtIndex:aCarousel.currentItemIndex];
    [_label1 setText:[NSString stringWithFormat:@"%ld/%lu", (long)aCarousel.currentItemIndex+1,(unsigned long)[animals count]]];


- (IBAction)btnBackAct:(UIButton *)sender

    [carousel removeFromSuperview];
    //[carousel scrollToItemBoundary];
    [carousel scrollToItemAtIndex:0 animated:NO];
    [self.navigationController popViewControllerAnimated:YES];    

【问题讨论】:

图片在资产中还是已下载? 它们已被下载。 在展示轮播之前还是展示时? 在显示轮播之前 你有两次 viewForItemAtIndex 【参考方案1】:

尝试:

- (IBAction)btnBackAct:(UIButton *)sender

    [carousel scrollToItemAtIndex:0 duration:0.01];
    [self performSelector:@selector(popMyView) withObject:nil afterDelay:0.02];


-(void)popMyView

    [self.navigationController popViewControllerAnimated:YES];

【讨论】:

这个问题只有在我设置动画打开时才会出现。

以上是关于屏幕转换期间 iCarousel Sticks的主要内容,如果未能解决你的问题,请参考以下文章

iCarousel 配置任务

为啥当我切换到上一个屏幕时,iCarousel 视图中的图像会显示在上一个屏幕中?

iCarousel 上的缩放变换显示屏幕外的区域

iCarousel 居中项目的位置 (iOS)

iCarousel 线性类型从中心开始

在 ICarousel 中调整滑块图像的大小