Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 当集合子视图的大小增加时,应用程序运行较慢?_Iphone_Ios_Objective C_Performance_Uicollectionview - Fatal编程技术网

Iphone 当集合子视图的大小增加时,应用程序运行较慢?

Iphone 当集合子视图的大小增加时,应用程序运行较慢?,iphone,ios,objective-c,performance,uicollectionview,Iphone,Ios,Objective C,Performance,Uicollectionview,我正在为我的通用应用程序使用UICollectionView。在每个集合视图单元中,我有一个自定义视图,它最终保存了一个图像。每个单元格代表一张扑克牌,所以当点击时,它会从前到后翻转。我遇到的问题是当我放大子视图的大小时。如果我把它放在小牢房里,一切都会好的。没有任何形式的减速。如果我将子视图放大到更大,就会出现严重的减速。不仅当我在集合视图上下滚动时,而且当我点击单个单元格时。延迟发生在一行单元格从屏幕外发出时。当我轻触一张“卡片”时,它也会前后翻转 这个问题似乎只存在于iPad版的应用程序中

我正在为我的通用应用程序使用UICollectionView。在每个集合视图单元中,我有一个自定义视图,它最终保存了一个图像。每个单元格代表一张扑克牌,所以当点击时,它会从前到后翻转。我遇到的问题是当我放大子视图的大小时。如果我把它放在小牢房里,一切都会好的。没有任何形式的减速。如果我将子视图放大到更大,就会出现严重的减速。不仅当我在集合视图上下滚动时,而且当我点击单个单元格时。延迟发生在一行单元格从屏幕外发出时。当我轻触一张“卡片”时,它也会前后翻转

这个问题似乎只存在于iPad版的应用程序中。当我在我的iPhone上运行它时,在延迟方面根本没有问题

为什么会发生这种情况,有什么原因吗

编辑以添加代码:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                  cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Card" forIndexPath:indexPath];

    Card *card = [self.game getCardFromPlayAtIndex:indexPath.item];

    [self updateCell:cell usingCard:card withAnimation:NO];


    return cell;
}
上面使用的抽象方法:

- (void)updateCell:(UICollectionViewCell *)cell usingCard:(Card *)card withAnimation:(BOOL)isAnimated
{
    // Using introspection to make sure that our cell is a PlayingCardCollectionViewCell
    if ([cell isKindOfClass:[PlayingCardCollectionViewCell class]]) {

        // If it is we an take that cell and cast it to a PCCVC and then pull out it's
        // outlet for the PlayingCardView
        PlayingCardView *playingCardView = ((PlayingCardCollectionViewCell *)cell).playingCardView;

        if ([card isKindOfClass:[PlayingCard class]]) {
            PlayingCard *playingCard = (PlayingCard *)card;

            playingCardView.rank = playingCard.rank;
            playingCardView.suit = playingCard.suit;


            playingCardView.faceUp = playingCard.isFaceUp;

            playingCardView.alpha = playingCard.isUnplayable ? 0.3 : 1.0;
        }

    }

}

您正在使用重用队列,对吗?不是自己维护单元格吗?我确实在使用重用队列。单元没有单独的管理。我已经为维护非常大的数据集的集合视图编写了测试用例,所以我认为它与CV本身无关。这只是一个玩笑,但是渲染是否有一些代价高昂的地方?当您放大视图大小时,代价就变得明显了?如果您可以在“cellForItemAtIndexPath:”中发布全部或部分代码,这将非常有帮助CVs上的大多数滞后问题都来自于对数据源的访问,我敢打赌这与重新缩放图像有关。这通常是瓶颈。