Papercloud / KeyboardConstraint

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

Calculate constraint update based on converted rect. #2

Open markst opened 9 years ago

markst commented 9 years ago
    UIView * superview = [(UIView *)self.firstItem superview];
    CGRect keyboardFrame = [superview.window convertRect:keyboardFrame toView:superview.superview];
    CGFloat inset = superview.frame.origin.y + superview.frame.size.height - keyboardFrame.origin.y;
ezescaruli commented 9 years ago

@markst This could be of your interest: https://github.com/Papercloud/KeyboardConstraint/commit/885d7fb3d80c367ed0c2bec71f99950a1e474f7

I'm basically doing [superview convertRect:superview.bounds toView:nil], to use that view's frame relative to the current window, before subtracting CGRectGetMinY(endFrame).

My logic behind that is that endFrame is always relative to the current window, so the subtraction should use two rects in the same coordinate system.