vtourraine / AcknowList

Acknowledgements screen displaying a list of licenses, for example from CocoaPods and Swift Package Manager dependencies.
MIT License
784 stars 59 forks source link

First lines of license appear below navigation bar #44

Closed pepejeria closed 5 years ago

pepejeria commented 5 years ago

The first two lines of text will appear below the navigation bar when pushing in the AcknowViewController controller. This could be solved by using isTranslucent false on the navigation bar, but a better solution would be to use auto-layout in the AcknowViewController.

screen shot 2018-10-05 at 08 59 41 screen shot 2018-10-05 at 08 59 55 screen shot 2018-10-05 at 09 00 16
pepejeria commented 5 years ago

I solved this by overriding AcknowViewController:

class LicenseDetailsViewController: AcknowViewController {

    override init(acknowledgement: Acknow) {
        super.init(acknowledgement: acknowledgement)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        if #available(iOS 11.0, *) {
            textView?.contentInsetAdjustmentBehavior = .never
        }
        textView?.autoPinEdgesToSuperviewEdges()
    }

}

Here auto-layout is used to pin the textView's edges to the superviews and add set the textViews' contentInsetAdjustmentBehavior property to never.

pepejeria commented 5 years ago

Another solution that I tried was to set the AcknowViewController's edgesForExtendedLayout to [], but that causes problems with the translucent navigation bar.

vtourraine commented 5 years ago

Hello José, and thanks a lot for the feedback.

I’m trying to reproduce the issue you’re describing, but the initial scroll view offset seems fine to me (tested with iOS 9, iOS 11, iOS 12).

Are you sure you’re using the latest version of AcknowList? Can you try with the example project included in this repo?

pepejeria commented 5 years ago

I was unable to trigger this by modifying your example project. I have something like this in my app:

class ViewController: UIViewController {

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.setNavigationBarHidden(true, animated: true)
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        navigationController?.setNavigationBarHidden(false, animated: true)
    }

    @IBAction func pushAcknowList(_ sender: AnyObject) {
        let viewController = AcknowListViewController(fileNamed: "Pods-acknowledgements")
        navigationController?.pushViewController(viewController, animated: true)
    }
}

But couldn't trigger the issue. The UINavigationController is created programmatically. I guess this can be close then.