2016-07-20 6 views
0

UICollectionViewに問題があります。私はそれが細胞とそれが完全に要素であることを示すコレクションビューを作った。しかし、問題は、アプリケーションが開いているときにボトムセルが隠されていることです。その後、上にスクロールすると、コレクションビューセルの最後の行が開きます。それらを訂正する方法?以下のスクリーンショットを参照してください。どうもありがとう!コレクションビューのセルを整列する方法スウィフト2.0で正しく表示

それは

Screenshot one

。..画像(スクリーンショット1)以下のように示している。しかし、私は、スクロール初めてなしの画像(スクリーンショット2)以下のようなコレクションビューのセルを表示したい...

ScreenShot two

私の符号化法は以下のとおりです。

// ViewController.swift 

import UIKit 

class ViewController: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate{ 

    @IBOutlet var collectionView: UICollectionView! 

    var titles = ["Events","Visitor Space","Contact Us","Facebook","Videos","WebSite"] 
    var icons = [UIImage(named: "cover"),UIImage(named: "cover"),UIImage(named: "cover"),UIImage(named: "cover"),UIImage(named: "cover"),UIImage(named: "cover")] 

    override func viewDidLoad() { 
     super.viewDidLoad() 
    } 


    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
     return titles.count 
    } 

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
     let cell = self.collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! HomeCollectionCells 
     cell.homeLabel.text = titles[indexPath.row] 
     cell.homeImage.image = icons[indexPath.row] 
     return cell 
    } 
    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
    }   
} 

答えて

1

viewDidLoad

self.automaticallyAdjustsScrollViewInsets = false 
+0

うわー大でこれを追加しよう!それは動作します...あなたのように多くのボス:);):D –

+0

ようこそメイトハッピーコーディング:) –

関連する問題