Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
- @IBOutlet weak var collectionView: UICollectionView!
- var tableData: [String] = ["Evo X", "458", "GTR"]
- var tableImages: [String] = ["1.png", "2.png", "3.png"]
- override func viewDidLoad() {
- super.viewDidLoad()
- self.collectionView.pagingEnabled = true
- // var layOut : UICollectionViewFlowLayout = UICollectionViewFlowLayout()
- // layOut.scrollDirection = UICollectionViewScrollDirection.Horizontal
- // self.collectionView.setCollectionViewLayout(layOut, animated: true)
- }
- func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return tableData.count
- }
- func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
- let cell: CollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as CollectionViewCell
- cell.lblCell.text = tableData[indexPath.row]
- cell.imgCell.image = UIImage(named: tableImages[indexPath.row])
- return cell
- }
- func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
- println("Cell \(indexPath.row) selected")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment