2014-10-08 86 views
1

我試圖實現類似於谷歌+動畫顯示新的UITableViewCells時,他們第一次出現。UITableViewCell動畫中斷UITableView觸摸檢測和滾動

這是我在做什麼:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if([[self serverFetchControllerForTableView:tableView] hasDataAtIndexPath:indexPath]) 
    { 
     if (![[self shownIndexesForTableView:tableView] containsObject:indexPath]) { 
      [[self shownIndexesForTableView:tableView] addObject:indexPath]; 

      UIView* view = [cell contentView]; 
      view.layer.transform = self.initialTransformation; 
      view.layer.opacity = 0.0; 

      [UIView animateWithDuration:ANIMATION_CELL_APPEARANCE_TIME animations:^{ 
       view.layer.transform = CATransform3DIdentity; 
       view.layer.opacity = 1; 
      }]; 
     } 
    } 
} 

//initial transformation looks like that 
CGFloat rotationAngleRadians = ANIMATION_CELL_APPEARANCE_ANGLE_DEG * (M_PI/180); 
CATransform3D transform = CATransform3DIdentity; 
transform = CATransform3DRotate(transform, rotationAngleRadians, 1.0, 0.0, 1.0); 
transform = CATransform3DTranslate(transform, ANIMATION_CELL_APPEARANCE_X, ANIMATION_CELL_APPEARANCE_Y, 0.0); 
self.initialTransformation = transform; 

一切正常,在視覺效果方面,但而那些細胞的出現,我失去的UITableView的滾動完全控制 - 我不能碰細胞,停止滾動或者選擇它們中的任何一個,直到動畫完成。

有沒有人有任何建議我可以在這裏做得更好來解決這個問題?

同樣的問題可以在這裏找到: http://www.raywenderlich.com/49311/advanced-table-view-animations-tutorial-drop-in-cards

嘗試把時間3.0秒在TipInCellAnimator任何3.0控制完全喪失。

回答

2

這是使用animateWithDuration...方法之一的動畫的正常行爲。如果您想在動畫過程中進行用戶交互,請嘗試使用 animateWithDuration:delay:options:animations:completion:並通過UIViewAnimationOptionAllowUserInteraction作爲選項。我不知道你的動畫可能會做什麼,但它應該允許用戶交互。

+0

好的作品!學過的知識 :) – 2014-10-09 08:48:35