Ios 如何将滑动和标题视图添加到uiTableView控制器。?
我已经添加了一个标题视图并向左滑动到表视图控制器 正如你在屏幕截图中看到的那样,当我滑动该行时,标题视图也在移动,请帮助我 我要添加标题的代码是Ios 如何将滑动和标题视图添加到uiTableView控制器。?,ios,uitableview,swift3,swipe,Ios,Uitableview,Swift3,Swipe,我已经添加了一个标题视图并向左滑动到表视图控制器 正如你在屏幕截图中看到的那样,当我滑动该行时,标题视图也在移动,请帮助我 我要添加标题的代码是 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let header = tableView.dequeueReusableCell(withIdentifier: "Heade
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = tableView.dequeueReusableCell(withIdentifier: "HeaderCell") as! CustomHeaderTableViewCell
header.SortButton?.backgroundColor = UIColor(netHex:0xEEEEEE)
header.FilterButton?.backgroundColor = UIColor(netHex:0xEEEEEE)
header.SortButton?.font = UIFont.fontAwesome(ofSize: 18)
header.SortButton?.text = String.fontAwesomeIcon(name: .sort) + " Sort"
header.FilterButton?.font = UIFont.fontAwesome(ofSize: 18)
header.FilterButton?.text = String.fontAwesomeIcon(name: .filter) + " Filter"
return header
}
func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let more = UITableViewRowAction(style: .normal, title: "More") { action, index in
print("more button tapped")
}
more.backgroundColor = .lightGray
let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
print("favorite button tapped")
}
favorite.backgroundColor = .orange
let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
print("share button tapped")
}
share.backgroundColor = .blue
return [share, favorite, more]
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
searchBar.endEditing(true)
let translation = scrollView.panGestureRecognizer.translation(in: scrollView.superview)
if(translation.y > 0)
{
// react to dragging down
} else
{
// react to dragging up
}
}
请帮我解决刷卡的问题
还有一件事,我可以在scroll上隐藏标题视图。您正在使用UITableViewCell子类作为标题视图。使用有两种可能的解决方案: 只需返回cell.contentView而不是viewForHeaderInSection函数中的单元格,您的问题就会得到解决。 标题视图的子类UITableViewHeaderFooterView,而不是UITableViewCell。