ユニバーサル アプリに 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;
}
}
}