Skip to content

Instantly share code, notes, and snippets.

@vin-the-dev
Last active April 6, 2016 09:24
Show Gist options
  • Save vin-the-dev/b22982649ee8de84ca15ed103c0eb709 to your computer and use it in GitHub Desktop.
Save vin-the-dev/b22982649ee8de84ca15ed103c0eb709 to your computer and use it in GitHub Desktop.
Load TableView in xib
// Create a xib with TableView
// Create a xib with TableViewCell
// Connect the TableViewCell xib to a class
//http://stackoverflow.com/questions/24056183/uitableview-using-swift
//http://stackoverflow.com/questions/26081287/required-initializer-initcoder-must-be-provided-by-subclass-of-uitablevi?rq=1
//swift file of TableViewCell
class TapCell1: UITableViewCell {
@IBOutlet weak internal var _lbl: UILabel!
required init(coder decoder: NSCoder) {
super.init(coder: decoder)!
}
override init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: UITableViewCellStyle.Value1, reuseIdentifier: reuseIdentifier)
}
}
// below in TableView View Page
// after setting datasource and delegalte for the TableView
let nibName = UINib(nibName: "TapCell1", bundle: nil)
self._tableView.registerNib(nibName, forCellReuseIdentifier: "Cell")
// in cell for index
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as TapCell1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment