2013-02-27 3 views
1

애니메이션으로 컬렉션을 다시로드하고 싶습니다. 나는 문서를 통해 갔고, 그들은 아래의 방법을 제공했다. 나는 그것을 사용했다. 잘 작동합니다. 이제 애니메이션의 속도 (느리게/빠름)를 처리하려고합니다. 이 방법으로 가능합니까?애니메이션이있는 리로드 컬렉션보기

- (void)performBatchUpdates:(void (^)(void))updates completion:(void (^)(BOOL finished))completion; 

내 코드 :

[mycollectionView performBatchUpdates:^{ 
    [mycollectionView reloadData]; 
    }; 

답변

2

는 잘 모르겠지만, 나는 단순히 performBatchUpdates: 전화를 통해 할 정말 가능하다고 생각하지 않는다, 나는 생각하지 않는다 그것은을 무시 의미가 있습니다 .

그러나이 작업을 수행하는 간단한 트릭 셀을 투명하게하고 호출하는 것입니다 UIView의의 animateWithDuration:animations: 예를 들어 collectionView:cellForItemAtIndexPath:

에서 :

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"SMSourceEntityCell"; 
    SMSourceEntityCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; 

    cell.backgroundImageView.alpha = 0.1; 
    cell.entityImageView.alpha = 0.1; 
    cell.entityImageEffect.alpha = 0.1; 

    [UIView animateWithDuration:2.0 animations:^{ 
     cell.backgroundImageView.alpha = 1; 
     cell.entityImageView.alpha = 1; 
     cell.entityImageEffect.alpha = 1; 
    }]; 

    return cell; 
} 
2

세포에 효과 및 애니메이션을 이동 추가 :

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

    CGFloat xx=cell.frame.origin.x; 
     CGFloat yy=cell.frame.origin.y; 



     CGRect frame = cell.frame; 
     frame.origin.x = 500; // new x coordinate 
     frame.origin.y = 0; // new y coordinate 
     cell.frame = frame; 


     [UIView animateWithDuration:2.0 animations:^{ 

      CGRect frame = cell.frame; 
      frame.origin.x = xx; // new x coordinate 
      frame.origin.y = yy; // new y coordinate 
      cell.frame = frame; 
      // cell.entityImageEffect.alpha = 1; 
     }]; 

    return cell; 

    } 
+0

이것을 추가했지만 뷰를 스크롤 할 때마다 재사용 가능한 셀이 만들어 질 때마다 매번 애니메이션이 적용됩니다. –

0

휴. 조금 늦었지만 셀 내용을 캐싱하는 경우 아직 캐시되지 않은 항목에 애니메이션을 적용하고 캐시 된 셀을 그대로 표시 할 수 있습니다. 그런 식으로 재사용되는 셀의 셀 애니메이션을 반복하지 않습니다.