2012-11-14 2 views
0

ViewController에서 프로그래밍 방식으로 Collection View를 구현하고 스토리 보드에 연결했지만 스크롤이 작동하지 않고 오른쪽으로 희미 해져서 셀의 절반이 나타나지 않습니다.setScrollDirection : CollectionView가 작동하지 않습니다.

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    [self.collectionView registerClass:[FotoCell class] 
      forCellWithReuseIdentifier:@"cell"]; 

    UICollectionViewFlowLayout *myLayout = [[[UICollectionViewFlowLayout alloc]init]autorelease]; 
    [myLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; 
    [self.collectionView setCollectionViewLayout:myLayout]; 

} 

이유를 알고 계십니까? 다음과 같이

답변

1

당신은있는 viewDidLoad에있는 registerClass 라인을 제거하고 UICollectionViewDelegate에 대한 데이터 소스 방법에 재사용 식별자를 설정해야합니다 -

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:  (NSIndexPath *)indexPath 
{ 
    FotoCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]; 

    .... 

    return cell; 
} 
관련 문제