2015-01-26 4 views
2

우리의 앱에는 사용자가 섹션을 최소화/최대화 할 수있는 tableview가 있습니다. 또한 사용자의 입력에 따라 행을 숨기거나 표시하는 애니메이션은 물론 Bluetooth 4.0을 통해 다른 장치에 연결되는 애니메이션도 있습니다. 애니메이션의 출처가 다르기 때문에 한 번에 하나의 애니메이션을 처리하도록 스케줄러를 설정하여 [tableview endUpdates] 이후에 동기화되지 않는 행/섹션의 수가 줄어들지 않도록했습니다. 우리의 목적을 위해 정말 잘 작동하고 있습니다.CATransaction insertRowsAtIndexPaths, 애니메이션이 끝나지 않습니다

그러나 우리 테이블의 새로운 섹션은 나에게 조금 슬픔을 안겨주었습니다. iPad에 연결된 장치에 따라 섹션에 1 행이 있거나 8-9 행이 있습니다. 나머지 행은 높이가 0입니다.이 섹션은 8-9 행이있을 때 잘 최소화/최대화합니다. 섹션에 행이 하나만있는 경우 섹션의 행이 화면에서 벗어날 때까지 테이블의 insertRowsAtIndexPaths 애니메이션이 완료되지 않습니다. 따라서 사용자가 탭을 변경하거나 테이블에서 화면 밖으로 밀어 내릴 수있을만큼 멀리 아래로 스크롤하지 않으면 이미 사용중인 경우 먼저 스케줄러가 확인하므로 다른 섹션을 최소화하거나 최대화 할 수 없습니다. 여기에 애니메이션을 위해 호출되는 코드입니다 :

-(void)animateTableUsingAnimationType:(NSNumber*)aniType 
{ 
    static int animationID = -1; 
    if(tableAnimationBusy) 
    { 
     [self performSelector:@selector(animateTableUsingAnimationType:) withObject:aniType afterDelay:.05f]; 
    } 
    else 
    { 
     tableAnimationBusy = true; 
     tat = [aniType intValue]; 
     [CATransaction begin]; 
     [CATransaction setCompletionBlock:^{ 
      NSLog(@"Animation %d is complete!", tat); 
      tableAnimationBusy = false; 
     }]; 

     //if-else if blocks checking for the animationID 
     //if open section 2 
      [self animateOpenTableSection:2] 
     else //undefined ID 
      tableAnimationBusy = false; 

     [CATransaction commit]; 
     [self setUpLabelText]; 
    } 
} 

은과 animateOpenTableSection입니다 : 당신이 볼 수 있듯이

-(void)animateOpenTableSection:(NSInteger)section 
{ 
    NSLog(@"Calling open on section: %d", section); 
    if (section == 2) 
    { 
     [self.tableView beginUpdates]; 
     openFlagSettingsRowCount = fsr_COUNT; //max row count for section 

     [[MCUISectionHandler sharedInstance] sectionTouched:YES forSection:MCUISH_SECTION_NAME__FLAG]; 
     NSMutableArray *indexPathsToInsert = [[NSMutableArray alloc] init]; 
     for (NSInteger i = 0; i < fsr_COUNT; i++) { 
      [indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:section]]; 
     } 
     [self.tableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationFade]; 
     [self.tableView endUpdates]; 
    } 
} 

, 내가 완료 블록뿐만 아니라의 animateOpenTableSection 기능에 디버그 문을 animateTableUsingAnimationType에 있습니다. 후자는 단일 행이 화면에서 사라질 때까지 호출되지 않습니다. tableview가 CATransaction을 놓아주지 않는 이유에 대한 아이디어가 있습니까?

답변

1

우리는이 문제를 해결할 수 있었고 우리 앱에 대해 알아 낸 것을 게시하는 것을 잊어 버렸습니다. tableview가 CATransaction을 허용하지 않는 이유는 행의 UIActivityIndicator 하위 뷰 때문입니다. 그것들은 움직이고 있었기 때문에 하나 이상의 UIActivityIndicators가 애니메이션을 멈출 때까지 기다리기 때문에 CATransaction이 끝나지 않았습니다.

따라서이 문제가 발생할 수있는 사용자는 애니메이션이 적용되는 하위보기가 있는지 확인하십시오.

관련 문제