0

this the first screenshort

enter image description here

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 .

2 Answers 2

1

There are 2 possible solutions to your problem:

  1. Simply return cell.contentView instead of cell within your viewForHeaderInSection function and your problem will be resolved.
  2. Subclass UITableViewHeaderFooterView instead of UITableViewCell for your Header view.
Sign up to request clarification or add additional context in comments.

Comments

0

You are using UITableViewCell subclass as a Header view. Instead use UITableViewHeaderFooterView

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.