【问题标题】:iOS iCarousel reuse for different albums retains old album info issueiOS iCarousel 重用不同专辑保留旧专辑信息问题
【发布时间】:2012-11-26 19:20:30
【问题描述】:

我正在使用 Nick Lockwood 的 iCarousel。优秀作品。 在将新专辑加载到轮播之前,我需要以某种方式重置/清除轮播。

背景: 应用程序从 API 中提取 XML 并将其解析为数组。 TableView 使用第一个 xml 作为专辑列表。 当用户选择/点击相册时,我会使用 iCarousel 推送查看。 用户可以备份并选择另一个相册

第一张专辑效果很好。 只要之后挑选的任何专辑都具有与第一张一样多或更多的照片,就可以正常工作。 当用户选择的相册比选择的第一个相册少时,会发生炸弹。

错误在:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
...//('thumbs' is thumbnail array)
 APIContentObject *currentPhoto = [thumbs objectAtIndex:index];        
...
}

希望将我的数组同步到 iCarousel,当 index 为 6 且 array.count 为 4 时,它会尝试加载“[thumbs objectAtIndex:index]”...

我试过 carousel=nil;在 viewWillDisappear 上,不。 是我做一个轮播=nil;在 ViewDidLoad 中,我什么也得不到……它是什么时候实例化的?在 ViewDidLoad 之前?

我真的只需要知道如何清空它或清除它或重新定位/初始化它。 我尝试了一个'for'循环来手动删除itematindex,但我也有错误..

它确实有效,只是不像预期的那样。律的建议? 非常感谢。

编辑: 好的,当我使用时:

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel
{
    //return the total number of items in the carousel
    return [thumbs count];
}

设置可见项目的数量...这似乎是一个兴趣点。 如果我不设置它/使用这个代码块,那么只会显示 7 张左右的图像......如果我设置它,它们都会显示出来,但是当点击图像数量较少的专辑时它会爆炸。 我在这个上兜圈子。

【问题讨论】:

    标签: icarousel


    【解决方案1】:

    从另一篇关于回收问题的帖子中获得线索。

    我接到了我的要求,将图像加载到回收器中......(ProgrammerError *ME!)

    if (view == nil)
        {...
        [((FXImageView *)view) setImageWithURL:[NSURL URLWithString:currentPhoto.ThumbnailURL] placeholderImage:[UIImage imageNamed:@"loading.png"]];
        ...}
    

    把它移到条件之外,然后 whamo... 好多了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多