andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 633 forks source link

TableView Sections not moving #283

Open axmav opened 7 years ago

axmav commented 7 years ago

Hello! Thank you for your library! I note that Table view sections do not moving when scrolling enabled.

import UIKit
import AMScrollingNavbar

class TVCTableViewController: UITableViewController {

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        if let navigationController = navigationController as? ScrollingNavigationController {
            print("FOLLOW")
            navigationController.followScrollView(tableView, delay: 0)
        }
    }

    override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60))
        view.backgroundColor = .red
        return view
    }

    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 60.0
    }

    // MARK: - Table view data source

    override func numberOfSections(in 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 20
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)

        return cell
    }

}

simulator screen shot - iphone 7 - 2017-10-23 at 10 08 44 simulator screen shot - iphone 7 - 2017-10-23 at 10 08 48

hardikdarji commented 6 years ago

I also have the same issue. Have you found any solution?

StefaniOSApps commented 6 years ago

This issue happens only by isTranslucent true. By isTranslucent false it works perfectly.

StefaniOSApps commented 6 years ago

the reason is the safeArea.top = 44. I am working on it.