Skip to content

Unable to change PullUpController's height dynamically #56

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

Open
rajeshkumar71190 opened this issue Apr 17, 2019 · 3 comments
Open

Unable to change PullUpController's height dynamically #56

rajeshkumar71190 opened this issue Apr 17, 2019 · 3 comments

Comments

@rajeshkumar71190
Copy link

I have a UILabel with numberOfLines set to 0. Its height constraint is >=30. I want to change pullUpController's height depends on its subview's height. I don't have any method to call after the layout is updated.

@MarioIannotta
Copy link
Owner

Hello there,
did you try using the method updatePreferredFrameIfNeeded(animated: Bool)?
Note that you should update pullUpControllerPreferredSize (or pullUpControllerPreferredLandscapeFrame) before call that method.

@rajeshkumar71190
Copy link
Author

Yes. I have this code in ChildVC:PullUpController

override var pullUpControllerPreferredSize: CGSize {
    if #available(iOS 11.0, *) {
        return CGSize(width: UIScreen.main.bounds.width, height: contentView.bounds.height + self.view.safeAreaInsets.bottom)
    } else {
        return CGSize(width: UIScreen.main.bounds.width, height: contentView.bounds.height + self.bottomLayoutGuide.length)
    }
}
override func viewDidLayoutSubviews() {
    updatePreferredFrameIfNeeded(animated: true)
}

But ChildVC's y posistion is maxY in parent view controller.
Parent view controller's frame -> (0,0,414,736)
Child view controller's frame -> (0,736,414,0)
Child view controller's subview frame -> (0,-268,414,268)//268 is contentView.bounds.height

@adrianmacarenco
Copy link

Hi @MarioIannotta
Is there a way to do it?
I am trying to do something similar where I want to expand the pullUpControllerPreferredSize (height) manually but it doesn't work.

public override var pullUpControllerPreferredSize: CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: maxHeight)
}

Then I am changing the maxHeight value and calling:

viewController.updatePreferredFrameIfNeeded(animated: true)

The viewController doesn't update its height. Is that possible to do?

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