I have added one header view and swipe left to table view controller .
As u can see in screenshot when i swipe the row then the header view is also moving please help me.
my code to add header is
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
}
}
can please help me to solve the problem of swipe .
and one more thing can I hide the header view on scroll .
There are 2 possible solutions to your problem:
cell.contentView
instead of cell within your viewForHeaderInSection
function and your problem will be resolved.UITableViewHeaderFooterView
instead of UITableViewCell
for your Header view.