早上好,我需要在我的自定义tableViewController中没有dequeueReusableCellWithIdentifier实例化我的自定义单元格,名为“CustomCell”,因为这个函数,由于我认为没有必要描述现在,当我滚动的时候,我的单元格被错误替换(IE与最后一个单元格交换,等等)。Swift:创建静态自定义单元格没有dequeueReusableCellWithIdentifier
所以我的代码是一样的东西:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
-> CustomCell {
// NEW VERSION HERE ---------
var cell = CustomCell()
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.userInteractionEnabled = true
cell.clipsToBounds = false
// OLD VERSION HERE ---------
//var cell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath) as! CustomCell
// Configure my cells....
return cell
}
那么,这个版本(无dequeueReusableCellWithIdentifier),我没有更多的问题,电池的定位,但我不能点击/点或简单地“使用”我的自定义项目到单元格。
例如我一个datepicker这样的:
var dynamicPicker = UIDatePicker(frame: CGRectMake(0, 0, self.frame.width, 192.0))
dynamicPicker.date = date_
dynamicPicker.addTarget(self, action: "pickerChanged:", forControlEvents: UIControlEvents.ValueChanged)
view.addSubView(dynamicPicker)
,我甚至不能更改日期,我无法触碰或一般我不能与它进行交互。它看起来像“userInteractionEnabled是假的”,但它不是。
谢谢大家, 最好的祝福马可。