Advertisement
drolloing

Adding various content type within Table View Cell

Jul 17th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  MyCell.swift
  3. //  tableViewSwift
  4. //
  5. //  Created by Kaushik Das on 7/17/14.
  6. //  Copyright (c) 2014 Kaushik Das. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import UIKit
  11.  
  12. class MyCell: UITableViewCell{
  13.     @IBOutlet var cellMyImage: UIImageView
  14.     @IBOutlet var cellMyCity: UILabel
  15.     @IBOutlet var cellMyCountry: UILabel
  16.    
  17.     init(style: UITableViewCellStyle, reuseIdentifier: String!) {
  18.         super.init(style: style, reuseIdentifier: reuseIdentifier)
  19.     }
  20.    
  21.     override func awakeFromNib() {
  22.         super.awakeFromNib()
  23.     }
  24.    
  25.     override func setSelected(selected: Bool, animated: Bool) {
  26.         super.setSelected(selected, animated: animated)
  27.     }
  28. }
  29.  
  30.  
  31. //
  32. //  ViewController.swift
  33. //  tableViewSwift
  34. //
  35. //  Created by Kaushik Das on 7/17/14.
  36. //  Copyright (c) 2014 Kaushik Das. All rights reserved.
  37. //
  38.  
  39. import UIKit
  40.  
  41. class ViewController: UITableViewController {
  42.                            
  43.     override func viewDidLoad() {
  44.         super.viewDidLoad()
  45.         // Do any additional setup after loading the view, typically from a nib.
  46.     }
  47.  
  48.     override func didReceiveMemoryWarning() {
  49.         super.didReceiveMemoryWarning()
  50.         // Dispose of any resources that can be recreated.
  51.     }
  52.  
  53.     override func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
  54.         return 1
  55.     }
  56.    
  57.     override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
  58.         return 10
  59.     }
  60.    
  61.    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) -> UITableViewCell! {
  62.                 let kCellIdentifier:String  = "MyCell"
  63.             var cell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as MyCell!
  64.             if cell == nil {
  65.                 // register Custom UITableView Class to UITableView
  66.                 tableView.registerClass(MyCell.classForCoder(), forCellReuseIdentifier: kCellIdentifier)
  67.                 cell = MyCell(style: UITableViewCellStyle.Default, reuseIdentifier: kCellIdentifier)
  68.             }
  69.            
  70.         cell.cellMyCity.text="test city"
  71.         cell.cellMyCountry.text="test country"
  72.        
  73.         return cell
  74.     }
  75.    
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement