2012-09-29 1 views
12

서브 클래스가 UICollectionViewLayout인데 셀을 원으로 배치했습니다. 레이아웃은 shouldInvalidateLayoutForBoundsChange:에 대해 YES을 반환합니다. 회전에서 초기 위치에있는 셀은 페이드 아웃 최종 위치에있는 셀은 페이드.UICollectionView/UICollectionViewLayout 회전 또는 경계 변경에서 크로스 페이드를 사용하지 않도록 설정하는 가장 좋은 방법은 무엇입니까?

나는 페이드를 사용할 수 있으며, 아이템의 원은 단순히을에 나타납니다 내 레이아웃에 다음 코드를 추가하여 방향 변화와 함께 회전 :

문서 하지 않기 때문에 방법이 경계 변경에 호출되는 이유는 무엇
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { 
    return nil; 
} 

- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:(NSIndexPath *)itemIndexPath { 
    return [self layoutAttributesForItemAtIndexPath:itemIndexPath]; 
} 

는 그들이 제안하는 것? 문서에 콜렉션 뷰에서 항목을 삽입하고 제거하는 것과 관련하여 호출이 있다고합니다.

회전 중에 크로스 페이드를 비활성화하는 더 좋은 방법이 있습니까?

주 :

  • initialLayoutAttributesForAppearingItemAtIndexPath: 문서 기본적으로 방법은 nil을 반환하지만 super이 nil이 아닌 값을 반환에 호출하는 상태.
  • 은 내가 UICollectionView 방법 deleteItemsAtIndexPaths:, moveItemAtIndexPath:toIndexPath:insertItemsAtIndexPaths:에 상징적 중단 점을 설정하고 그들 중 누구도이 회전하는 동안 공격하지 않습니다.
+0

이것은 어둠 속의 단순한 장면이지만 회전 애니메이션을 비활성화하려면 회전 작업을 위해 코어 애니메이션을 완전히 종료 할 수 있습니다. [CATransaction begin]; [CATransaction setValue : (id) kCFBooleanFalse forKey : kCATransactionDisableActions]; // 회전하십시오 [CATransaction commit]; – maz

+0

아마도 내부적으로 바운드 변경에 따라 항목이 제거되고 추가되고 결과적으로 메서드가 호출됩니다. 이유에 관해서는 -deleteItemsAtIndexPaths :와 -insertItemsAtIndexPaths : do not called called .. 여기서는 아무런 단서도 없습니다. 아마도 UIKit 프로그래머는 속여서 삭제를 수행하기 위해 API를 속여서 피 했나? 전례가없는. – maz

+1

여기에서 설명하는 것과 같은 것을 사용하여보기의 배경 레이어에서 암시 적 애니메이션을 사용 중지 할 수 있습니까? http://stackoverflow.com/questions/2244147/disabling-implicit-animations-in-calayer-setneedsdisplayinrect/2244734#2244734? –

답변

10

UICollectionViewLayout.h 파일 상태를 명확하게 그들이 경계 변경에라고 말한다

// This set of methods is called when the collection view undergoes an 
    animated transition such as a batch update block or an animated 
    bounds change. 
// For each element on screen before the invalidation, 
    finalLayoutAttributesForDisappearingXXX will be called and an 
    animation setup from what is on screen to those final attributes. 
// For each element on screen after the invalidation, 
    initialLayoutAttributesForAppearingXXX will be called an an 
    animation setup from those initial attributes to what ends up on 
    screen. 

. 제거/삽입보다는 "오래된 상태"와 "새로운 상태"가 더 정확 해 보입니다.

관련 문제