0

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 top left tiny gray part is my cell and the green is the background

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")
Mahi008
  • 373
  • 2
  • 3
  • 22

1 Answers1

1

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.

Community
  • 1
  • 1
Rikkles
  • 3,372
  • 1
  • 18
  • 24
  • Thank's it works! Can you suggest a best way to put space between my cells? I mean space on left, right and bottom? – Mahi008 Aug 10 '14 at 10:46
  • Please ask a new question for that (after uou check for existing answers). Thanks. Also I'd appreciate your tagging this answer as accepted. – Rikkles Aug 10 '14 at 11:18