Created
March 3, 2017 08:31
-
-
Save BalajiMalliswamy/4a8d5109594d0f21f7d6ae844a1970b7 to your computer and use it in GitHub Desktop.
Image Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// StackoverflowWorks | |
// | |
// Created by Balaji Malliswamy on 03/03/17. | |
// Copyright © 2017 NFNLabs. All rights reserved. | |
// | |
import UIKit | |
class ImageArrayExample: UIViewController, UITableViewDelegate,UITableViewDataSource { | |
let titleText = ["YouTube","Facebook","Vimeo","Dailymotion"] | |
let images : [UIImage] = [#imageLiteral(resourceName: "YouTube"),#imageLiteral(resourceName: "Facebook"),#imageLiteral(resourceName: "Vimeo"),#imageLiteral(resourceName: "Dailymotion")] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return titleText.count | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) | |
cell.textLabel?.text = titleText[indexPath.row] | |
cell.imageView?.image = images[indexPath.row] | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment