2013-09-28 2 views
1

위로/아래로 스크롤하는 동안 UICollectionView의 방법을 아는 사람이 있습니까? 아래로 스크롤하는 동안 UICollectionView의 머리글을 변경해야합니다. 고유 한 일정보기를 수행하고 있습니다.Objective-C UICollectionView 위쪽/아래쪽 스크롤

나는 위로 스크롤하고있는 동안 헤더 섹션

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath 
{ 

    ASCalendarHeaderView *calHeader = [self.calCollectView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"CalendarHeader" forIndexPath:indexPath]; 

    calHeader.MonthYearLabel.text = [calendar getCurrentMonthYear:calendar.today]; 
    [calHeader setNeedsDisplay]; 
    calHeader.MonthYearLabel.textAlignment = NSTextAlignmentRight; 

    if (indexPath.section){ 

     [calendar getNextMonth:calendar.today]; 
     NSLog(@"Some Text"); 

    } 

    return calHeader; 
} 

보기 그러나 증가 달을 생성하는 방법을 다음했다. 스크롤하는 동안과 스크롤 할 때 별도로 사용하는 방법이 있습니까?

감사

답변

2

확인 스크롤 검출이 방법 : 당신이 그 위로 또는 아래로 스크롤 알고 싶은 경우에, 그것은 당신이 스크롤 할 때마다 호출됩니다

- (void)scrollViewDidScroll:(UIScrollView *)sender 

을의 오프셋 (offset)를 등록 이전 스크롤, 더 있다면, 당신은 올라가고 viceversa :

@property (nonatomic, assign) NSInteger lastOffset; 

- (void)scrollViewDidScroll:(UIScrollView *)sender 
{ 
    //Compare sender.contentOffset.y with lastOffset 

lastOffset = sender.contentOffset 

} 
+0

죄송합니다, 내가 어떻게 할 수있는이 메서드에서 CollectionView에 대한 헤더 변경합니까? – Anton

+0

매번 새로운 헤더를 만드는 대신, 헤더에 클래스 변수를 넣고 메소드에 반환하면됩니다. 그것은 클래스 변수이기 때문에 원하는 때마다 원하는 값으로 변경할 수 있습니다. –

+0

몇 가지 예를 들어 주시겠습니까? – Anton

관련 문제