Swift自定义UITableviewCell宽度问题

时间:2014-08-08 20:03:57

标签: xcode uitableview swift

我已经在xcode 6 beta(5)中创建了一个自定义UITableviewCell,但是在模拟器上进行测试看起来太小了,我尝试使用属性检查器设置宽度,但它没有工作。我使用.xib文件创建它,我在mainViewController中注册它以使用它与连接的tableView

这就是它在模拟器中的样子

The top left tiny gray part is my cell and the green is the background

代码的单元格部分,我的自定义类名称为CustomCell

 var cell:CustomCell = self.tableview.dequeueReusableCellWithIdentifier("cell") as CustomCell
 cell.txt.text="\(ListArray.objectAtIndex(indexPath.row))"   
 return cell

这是我在viewDidLoad

中注册的方式
 var nipName=UINib(nibName: "CustomCell", bundle:nil)
 self.tableview.registerClass(CustomCell.classForCoder(), forCellReuseIdentifier: "cell")
 self.tableview.registerNib(nipName, forCellReuseIdentifier: "cell")

1 个答案:

答案 0 :(得分:1)

看看我对UILabels in custom UITableViewCell never gets initialized的回复。首先,heightForRowAtIndexPath函数中的代码。其次,根据您设置nib / storyboard的方式,如果已将tableview连接到自定义视图,请删除registerClass。否则它将断开你的笔尖连接并重新创建一个新连接,消除你在笔尖中所做的所有自定义。

相关问题