###前提・実現したいこと
CollectionViewを使った横スクロール(ページング)実装時に、
ページを捲るごとにずれていってしまうのですが、こちらはどのように修正したら良いでしょうか。
###該当のソースコード
Swift
1import UIKit 2 3class ViewController: UIViewController, UICollectionViewDataSource { 4 5 @IBOutlet weak var collectionVIew: UICollectionView! 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 // Do any additional setup after loading the view, typically from a nib. 10 } 11 12 override func didReceiveMemoryWarning() { 13 super.didReceiveMemoryWarning() 14 // Dispose of any resources that can be recreated. 15 } 16 17 func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 18 return 3 19 } 20 21 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 22 let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CustomCell 23 return cell 24 } 25 26 func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { 27 let width = collectionView.frame.width 28 let height = collectionView.frame.height 29 30 print(width) 31 return CGSize(width: width, height: height) 32 } 33 34 35}
###補足情報(言語/FW/ツール等のバージョンなど)
・Xcode7.3.1
・Swift2.2
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。