Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PullUpView doesn't load properly when app loads #46

Open
santi-g-s opened this issue Jan 22, 2019 · 4 comments
Open

PullUpView doesn't load properly when app loads #46

santi-g-s opened this issue Jan 22, 2019 · 4 comments

Comments

@santi-g-s
Copy link

Hi, thanks for the great work you've done. But, when my app initially loads, the view is shown much lower than it should be when collapsed. Once I swipe up to open it, however, it returns to the correct height when collapsed and expanded. I have set the height of the collapsed view to be a view container I have in the PullUpView.

@santi-g-s
Copy link
Author

santi-g-s commented Jan 30, 2019

Here is what it should look like when it starts:

img_3912

This is what I get

img_3910

@MarioIannotta
Copy link
Owner

It is really hard to understand the issue here.
My guess here is that you are calling the method addPullUpController(<#T##PullUpController#>, initialStickyPointOffset: <#T##CGFloat#>, animated: <#T##Bool#>) using a wrong value as initialStickyPointOffset or when your view's layout is not ready.

Could you please provide an example of the issue using the demo project?

@santi-g-s
Copy link
Author

Here's the code I use to make the pullUpController.

private func makeViewController() -> ViewController {
        let currentPullUpController = children
            .filter({ $0 is ViewController })
            .first as? ViewController
    let pullUpController: ViewController = currentPullUpController ?? UIStoryboard(name: "Main",bundle: nil).instantiateViewController(withIdentifier: "ViewController") as! ViewController
    pullUpController.initialState = .contracted
    if originalPullUpControllerViewSize == .zero {
            originalPullUpControllerViewSize = pullUpController.view.bounds.size
        }
    return pullUpController
    }

I add it to the view with this (had to add 15 so that i can at least see it)

private func addPullUpController() {
        
        let pullUpController = makeViewController()
        _ = pullUpController.view
        print(pullUpController.initialPointOffset)
        addPullUpController(pullUpController,
                            initialStickyPointOffset: pullUpController.initialPointOffset + 15,
                            animated: true)
        
    }

The initialPointOffset is set up as follows:

var initialPointOffset: CGFloat {
        switch initialState {
        case .contracted:
            return containerView?.frame.height ?? 0
        case .expanded:
            return pullUpControllerPreferredSize.height
        }
    }

And the prefferedSize comes from the portrait Size.

The confusing bit is that this only happens when the app is loaded initially. After that the sticky points are correct.

@evtaccount
Copy link

@santi-g-s navigationBar is the reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants