2016-09-14 42 views
1

4つのセルを含むUICollectionViewがあります。 4つのセルの最後が画面の途中にあります。 4つのセルのうちの最初のセルが画面の途中に配置されるように、プログラムで右にスクロールするにはどうすればよいですか?水平スクロールa UICollectionViewを右端または最後のセルまで移動

私が試してみた:

それが今ではどのよう
if (self.activeSection == .WISHES){ 
    cell.neighbourhoodHeaderCollectionView.setContentOffset(CGPointMake(CGFloat.max, 0), animated: false) 
} 

enter image description hereそれはする必要がありますどのように

enter image description here

+0

'setContentOffset'の代わりに' scrollToItem'([docs](https://developer.apple.com/reference/uikit/uicollectionview/1618046-scrolltoitem))を使ってみてください – spassas

+0

私は試しました。何も変わらない –

答えて

1

これを使用し...

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ 
    return UIEdgeInsetsMake(0/*top*/, 5/*left*/, 0/*bottom*/, 5/*right*/); 
} 
+0

私のビューでは何も変わらない –

+0

いいえ、あなただけが右と左のエッジを設定します... – Rahul

+0

私は試しましたが、それでも私のために働いていません。 –

関連する問題