0

그래서 UICollectionView가 있는데, 포커스가 새 셀로 바뀌면 셀의 이미지가 확장되도록 만들었습니다. 어떤 이유로 UICollectionView가 첫 번째 셀을로드 할 때마다 나머지 셀보다 큽니다 (아래 스크린 샷 참조). 이 작업을 중단하려면 어떻게해야합니까? 초점의 이미지를 변경UICollectionView 첫 번째 셀이 tvOS에서 나머지 부분보다 많이로드됩니다.

enter image description here

내 코드는 다음과 같습니다 이것보다 다른

- (void)collectionView:(UICollectionView *)collectionView didUpdateFocusInContext:(UICollectionViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator { 

    NSIndexPath *previousIndexPath = context.previouslyFocusedIndexPath; 
    NSIndexPath *indexPath = context.nextFocusedIndexPath; 

    TrophyCollectionViewCell *previousCell = (TrophyCollectionViewCell *)[collectionView cellForItemAtIndexPath:previousIndexPath]; 
    TrophyCollectionViewCell *cell = (TrophyCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; 

    [UIView animateWithDuration:0.3 animations:^{ 

     if (previousCell.trophyImageView != nil) { 
      previousCell.trophyImageView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); 
     } 

     if (cell.trophyImageView != nil) { 
      cell.trophyImageView.transform = CGAffineTransformMakeScale(1.2f, 1.2f); 
     } 

     if (previousCell.resetImageView != nil) { 
      previousCell.resetImageView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); 
     } 

     if (cell.resetImageView != nil) { 
      cell.resetImageView.transform = CGAffineTransformMakeScale(1.2f, 1.2f); 
     } 

    }]; 

} 

내가 세포의 크기에 영향을 미치는 다른 코드가 없습니다.

답변

0

didUpdateFocusInContext 메서드에서 이전에 집중된 다음 집중된 셀에 대해 CGAffineTransformMakeScale(1.0f, 1.0f);을 설정하여이 문제를 해결할 수있었습니다.

관련 문제