khenid

Untitled

Feb 7th, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2.  
  3. class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
  4.  
  5.     @IBOutlet weak var collectionView: UICollectionView!
  6.    
  7.     var tableData: [String] = ["Evo X", "458", "GTR"]
  8.     var tableImages: [String] = ["1.png", "2.png", "3.png"]
  9.    
  10.     override func viewDidLoad() {
  11.         super.viewDidLoad()
  12.         self.collectionView.pagingEnabled = true
  13. //        var layOut : UICollectionViewFlowLayout = UICollectionViewFlowLayout()
  14. //        layOut.scrollDirection = UICollectionViewScrollDirection.Horizontal
  15. //        self.collectionView.setCollectionViewLayout(layOut, animated: true)
  16.     }
  17.    
  18.     func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  19.         return tableData.count
  20.     }
  21.    
  22.     func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
  23.         let cell: CollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as CollectionViewCell
  24.         cell.lblCell.text = tableData[indexPath.row]
  25.         cell.imgCell.image = UIImage(named: tableImages[indexPath.row])
  26.         return cell
  27.     }
  28.  
  29.      func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
  30.         println("Cell \(indexPath.row) selected")
  31.     }
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment