Closed Rich86man closed 8 years ago
Hi @Rich86man:
Could you please tell me exactly what you changed and how the whole code block turns out to be? I believe there's nothing wrong with the constraint-choosing logic in Popsicle, but let's make sure :)
let xInterpolation = Interpolation(imageView, centerXConstraint)
to
let xInterpolation = Interpolation(imageView, widthConstraint)
Looking at the storyboard there is a width constraint on the image view being interpolated.
I ran into the same issue in my own project when I tried to interpolate the width of an image view so I decided to try to interpolate a width of an object in the sample project.
I ended up doing something like this to achieve the effect
@IBOutlet weak var imageViewWidthConstraint: NSLayoutConstraint!
let constraintKeyPath = KeyPath<NSLayoutConstraint, CGFloat>(keyPathable: "constant")
let imageViewSize = Interpolation(imageViewWidthConstraint, constraintKeyPath)
But it would be nice to not need the extra outlet. Am I using it wrong?
But it would be nice to not need the extra outlet. Am I using it wrong?
Absolutely, that's the idea behind those constraint keypaths. Give me some time to discover what's the problem.
Oh shoot! I just realised what the problem is. Popsicle only checks the view's superview constraints, but unlike positioning constraints, width and height constraints are applied to the view itself, so Popsicle finds no width or height constraint attached to the superview.
I'll work out a solution and push it as 2.0.1.
Awesome. Thanks! Loving Popsicle btw
if you change line 54 of the demo project, the app with crash with
"fatal error: Please make sure the key path "NSLayoutAttribute.Width" you're referring to for an object of type is invalid: file /var/folders/hj/yvctlzcs65n1rlgrnvq712_h0000gn/T/CocoaPods/Try/Popsicle/Popsicle/Interpolation.swift, line 33
"
I looked in the storyboard are there are constraints for width and height. Am I doing something incorrect?