2014-01-22 43 views
3

我現在設置了水平滾動,我希望它可以一次滾動/捕捉一個單元格,當滾動左右移動時。iOS:一次滾動一個單元格

難道有人會發光嗎?這裏是我到目前爲止的代碼:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

#pragma mark - UICollectionView Datasource 

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 
    return 1; 
} 

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 
    return 20; 
} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { 
    MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath]; 
    cell.backgroundColor = [UIColor whiteColor]; 
    return cell; 
} 

#pragma mark - UICollectionViewDelegateFlowLayout 

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { 
    return UIEdgeInsetsMake(50, 20, 50, 20); 
} 
+0

的可能重複的[UICollectionView與尋呼 - 設置頁面寬度(http://stackoverflow.com/questions/20496850/uicollectionview-with-paging-setting-page-width) – diclophis

回答

相關問題