I am a bit of a novice with swift. I am trying to simply create a collection view that is placed within a specific region of the screen (landscape iPad iOS). It is possible that there is actually a collectionView bug... The following code produces the attached image. The problem is that the entirety of the collection view simply isn't displayed...
import UIKit
class ViewController: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
var collectionView: UICollectionView?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 300, left: 500, bottom: 30, right: 10)
layout.itemSize = CGSize(width: 32, height: 32)
collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collectionView!.dataSource = self
collectionView!.delegate = self
collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
collectionView!.backgroundColor = UIColor.whiteColor()
self.view.addSubview(collectionView!)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 40
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! UICollectionViewCell
cell.backgroundColor = UIColor.orangeColor()
return cell
}
}

Also, is there a way I can avoid using a FLOW LAYOUT? A rigid collection view is fine. I need a 10x10 collection view that won't vary in size or number of cells.
UIEdgeInsetsare huge. Try something smaller. For example,layout.sectionInset = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50)