Here's my code
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return 10
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell :UITableViewCell = tableView.dequeueReusableCellWithIdentifier("discovered") as UITableViewCell!
bluetoothlog.registerNib(UINib(nibName: "devicedet", bundle: nil), forCellReuseIdentifier: "discovered")
//NSBundle.mainBundle().loadNibNamed("devicedet", owner: nil, options: nil)[0] as UITableViewCell
cell = blucell
devname.text = peri[indexPath.row]
devstrength.text = signalstrength[indexPath.row]
bluetoothlog.backgroundColor = UIColor.clearColor()
return cell
}
I have tried with the above code and nothing is displayed in Tableview, please help me to change this code working
Thanks
My code:
In viewDidLoad register XIB as shown below
if you would like to Load custom cell(Xib) in UITableView in swift ,you may use the following code.
Don’t forget to register nib in viewDidLoad
Register your NIB with the reuse identifier:
Your cellForRowAtIndexPath would then instantiate the cell.
Added Screenshot for setting Datasource and delegate from storyboard
Your fuction registerNib , you try to write in viewDidLoad() method and remove from cellForRowAtIndexPah and then test your project
Your Cell Instance should be of CustomCell instance and not of UITableView Cell. var cell :UITableViewCell should be replaced by var cell :devicedet