Papercloud / KeyboardConstraint

A NSLayoutConstraint subclass which observes keyboard notifications.
MIT License
14 stars 2 forks source link

If constraint `firstItem` `superview` does not exist #5

Open markst opened 9 years ago

markst commented 8 years ago

@ezescaruli has this been an issue for you at any time?

ezescaruli commented 8 years ago

@markst

Nope actually, but I figure it could happen if the items are reversed, right? In that case firstItem ends up being the view controller's root view, and firstItem's superview could be nil.

Do you think it might be worth checking the secondItem's superview as well, to consider that scenario? Like:

UIView *superview = [(UIView *) self.firstItem superview];

if (superview == nil) {
    superview = [(UIView *) self.secondItem superview];
}

if (superview) {
    ...
}
markst commented 8 years ago

@ezescaruli this is true. But then I think this would be the incorrect usage of the constraint, since the value applied to the constant then need to be reversed also?

ezescaruli commented 8 years ago

@markst Fair point. Let's go with your fix then.