2013-10-21 4 views
0

UITableView의 섹션을 클릭하면 4 개의 애니메이션 셀이 드롭 다운됩니다. 그러나 문제는 드롭 다운 할 때 뷰 (스크린)를 지나갈 때 문제가 발생한다는 것입니다. 당신이 아래로 스크롤하지 않으면 그들을보십시오. 어떻게하면 섹션을 클릭하면 드롭 다운 메뉴의 모든 셀을 드러내 기 전체보기를 밀 수 있도록 그것을 만들까요? 여기 내 코드 :UITableView의 셀 애니메이션하기

- (void) sectionOpened : (NSInteger) section{ 

    SectionInfo *array = [self.sectionInfoArray objectAtIndex:section]; 
    array.open = YES; 

    NSInteger count = [array.category.list count]; 
    NSMutableArray *indexPathToInsert = [[NSMutableArray alloc] init]; 
    for (NSInteger i = 0; i<count;i++) 
    { 
     [indexPathToInsert addObject:[NSIndexPath indexPathForRow:i inSection:section]]; 
    } 

    NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init]; 
    NSInteger previousOpenIndex = self.openSectionIndex; 
    if (previousOpenIndex != NSNotFound) 
    { 
     SectionInfo *sectionArray = [self.sectionInfoArray objectAtIndex:previousOpenIndex]; 
     sectionArray.open = NO; 
     NSInteger counts = [sectionArray.category.list count]; 
     [sectionArray.sectionView toggleButtonPressed:FALSE]; 
     for (NSInteger i = 0; i<counts; i++) 
     { 
      [indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:previousOpenIndex]]; 
     } 
    } 
    UITableViewRowAnimation insertAnimation; 
    UITableViewRowAnimation deleteAnimation; 
    if (previousOpenIndex == NSNotFound || section < previousOpenIndex) 
    { 
     insertAnimation = UITableViewRowAnimationTop; 
     deleteAnimation = UITableViewRowAnimationBottom; 
    } 
    else 
    { 
     insertAnimation = UITableViewRowAnimationBottom; 
     deleteAnimation = UITableViewRowAnimationTop; 
    } 

    [atableView beginUpdates]; 

    [atableView insertRowsAtIndexPaths:indexPathToInsert withRowAnimation:UITableViewRowAnimationTop]; 
    [atableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation]; 


    [atableView endUpdates]; 

    self.openSectionIndex = section; 

} 

어떤 아이디어?

답변

0

이 tableView 메소드를 사용해 보셨습니까?

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated 

그래서 시도해 볼 수 있습니다.

[atableView scrollToRowAtIndexPath:indexPathToInsert atScrollPosition: UITableViewScrollPositionTop animated:YES]; 
+0

흠이 어떤 이유로 작동하지 않았습니까? –

+0

endUpdates 호출 후 수행 했습니까? – aahrens

관련 문제