UICollectionView 跳跃式滚动 [英] UICollectionView jumpy scrolling

查看:54
本文介绍了UICollectionView 跳跃式滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个可以容纳不同大小的视图"等的界面.为此,我将 UICollectionView 与这些单元格一起使用:

I am trying to create an interface that can hold "views" of different sizes etc. For this I am using a UICollectionView with these cells:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    Card *card = [[[usermanager getSelectedUser] getCards] objectAtIndex:indexPath.item];
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cardCell" forIndexPath:indexPath];
    [cell addSubview:card];

    [cell.layer setBorderColor:[UIColor redColor].CGColor];
    [cell.layer setBorderWidth:1.0f];
    [cell.layer setMasksToBounds:NO];
    return cell;
}

一切似乎都很好,直到卡片数量变得太大而我不得不滚动.滚动后抬起手指时,视图会跳动一点.我还遇到了其他一些奇怪的 UI 问题.从我读过的内容来看,这与滚动期间重新加载单元格有关.防止这种情况的正确方法是什么?

Everthing seems to work fine until the amount of cards becomes too big and I have to scroll. The view jumps a little bit when I lift my finger after scrolling. And I get some other weird UI issues. From what I have read this has to do with the reloading of the cells during scrolling. What would be the proper way to prevent that?

需要注意的是,内容是动态的.用户应该能够在运行时添加和移除卡片.

It is very important to note that the content is dynamic. The user should be able to add and remove cards at runtime.

谢谢

推荐答案

我有点想通了.我的一些卡片包含图像,每次我滚动系统时,系统都会从内存中重新加载所有这些图像.这使得滚动相对缓慢且断断续续.

I sort of figured it out. Some of my cards contained images, and everytime I would scroll the system would reload all these images from the memory. This made scrolling relatively slow and choppy.

这篇关于UICollectionView 跳跃式滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆