Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
  4.  
  5. @IBOutlet var tableView: UITableView!
  6. var name = ["Thinh", "Nhut", "Truong", "Tuyet", "Hoai", "Hoang", "NSHipster", "iOS Developer Tips", "Jameson Quave", "Natasha The Robot", "Coding Explorer", "That Thing In Swift", "Andrew Bancroft", "iAchieved.it", "Airspeed Velocity"]
  7. var ngaysinh = ["10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991", "10/10/1991"]
  8. var namsinh = ["1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991", "1991"]
  9.  
  10.  
  11. override func viewDidLoad() {
  12. super.viewDidLoad()
  13. // Do any additional setup after loading the view, typically from a nib.
  14.  
  15. }
  16.  
  17. override func didReceiveMemoryWarning() {
  18. super.didReceiveMemoryWarning()
  19. // Dispose of any resources that can be recreated.
  20. }
  21.  
  22. public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  23. return name.count
  24. }
  25.  
  26. // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
  27. // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
  28.  
  29.  
  30. public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  31. let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as!CustomCell
  32.  
  33. cell.hoten.text = name [indexPath.row]
  34. cell.ngaysinh.text = ngaysinh [indexPath.row]
  35. cell.namsinh.text = namsinh [indexPath.row]
  36.  
  37. return cell
  38. }
  39.  
  40. func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  41. tableView.deselectRowAtIndexPath(indexPath, animated: true)
  42.  
  43. let row = indexPath.row
  44. print(name[row])
  45. print(ngaysinh[row])
  46. print(namsinh[row])
  47. }
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement