Reputation: 433
I have created a custom UITableviewCell in xcode 6 beta(5), but while testing on the simulator it looks too small, I tried to set the width using attribute inspector, and it didn't worked. I created it using a .xib file and I registered it in my mainViewController to use it with connected tableView
This is how it looks like in simulator
The cell part of the code, where my custom class name is CustomCell
var cell:CustomCell = self.tableview.dequeueReusableCellWithIdentifier("cell") as CustomCell
cell.txt.text="\(ListArray.objectAtIndex(indexPath.row))"
return cell
This is how I register in viewDidLoad
var nipName=UINib(nibName: "CustomCell", bundle:nil)
self.tableview.registerClass(CustomCell.classForCoder(), forCellReuseIdentifier: "cell")
self.tableview.registerNib(nipName, forCellReuseIdentifier: "cell")
Upvotes: 0
Views: 1450
Reputation: 3372
Take a look at my response to UILabels in custom UITableViewCell never gets initialized . First of all, code in the heightForRowAtIndexPath
function. Second, depending on how you set up the nib/storyboard, if it already connected the tableview to the custom view, get rid of registerClass
. Otherwise it'll disconnect your nib connection and recreate a new one, wiping out all the customization you did in the nib.
Upvotes: 1