對不起,我真的找不到這個地方。如何將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