문제 설명
UITableViewCell 탭 호버 (UITableViewCell tap hover)
내 tableviewcell에 회색 배경색이 선택되어 있습니다. 그러나 저는 실제로 tableview의 "선택된" 기능을 사용하지 않고 있습니다. 단지 호버 효과를 원하므로 다음과 같이 행이 선택된 직후에 선택을 취소합니다.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
문제는 회색 배경입니다. 셀을 조금 더 길게 탭할 때만 표시됩니다. 셀을 정말 빨리 탭하면 회색 배경이 보이지 않습니다.
이를 달성하는 방법이 있습니까?
감사합니다.
참조 솔루션
방법 1:
You can do this by either using touchesBegan
or touchesEnded
. If the touch is within your tableview cell you can add a little animation.
See the UIResponder Class
for more information:
방법 2:
You can use this on viewDidAppear to achieve this, as soon as you redirect to your view controller this method will deselect the selected item. Hope that this will help you :‑
override func viewWillAppear(animated: Bool) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
(by user3162662、Berendschot、Chathuranga Silva)