对不起,我真的找不到这个地方。如何将uitableviewcellselectionstyle.none设置为静态单元格?
我需要将我的选择样式设置为none,以便在点击它时行不会突出显示。此外,我需要行可以选择,因为我有一些行需要扩展和折叠。我知道这段代码是UITableViewCellSelectionStyle.None
,但我不知道我可以在哪里实现它。谢谢!
编辑加入码
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 7
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// Set height for date picker
if indexPath.section == 0 && indexPath.row == 2 {
let height:CGFloat = datePicker.hidden ? 0.0 : 216.0
return height
}
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Expanding and collapsing date picker
UITableViewCellSelectionStyle.None
let datePickerIndexPath = NSIndexPath(forRow: 1, inSection: 0)
if datePickerIndexPath == indexPath {
datePicker.hidden = !datePicker.hidden
UIView.animateWithDuration(0.3, animations: {() -> Void in
self.tableView.beginUpdates()
// apple bug fix - some TV lines hide after animation
self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
self.tableView.endUpdates()
})
}
}
的代码主要是针对我已实施的日期选择器。一切正常,但单击单元格会突出显示默认选择颜色的整行。
但目前我的表视图数据源的代码实际上是空的,因为我使用的是静态单元,实际上并没有任何显示。 也可以,'cellForRowAtIndexPath'可以用于静态单元格吗?我试过了,但是错误出现了 “终止应用程序,由于未捕获异常'NSInternalInconsistencyException',原因:'无法使具有标识符TransportExpenseCell0的单元出列 - 必须为标识符注册一个nib或类或连接故事板中的原型单元格' “ – Chris
,我确实有一个静态单元,其中带有标识TransportExpenseCell0的静态单元 – Chris
刚添加在代码 – Chris