-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I've tried KeyboardConstraint in an iPhone X and it's having an issue when the keyboard appears. It looks like this (note the space between the sign up button and the keyboard):
I debugged the point in which the keyboard appears:
| if ([self.firstItem conformsToProtocol:@protocol(UILayoutSupport)]) { |
and had this:
(lldb) po [self firstItem]
<UILayoutGuide: 0x6000005acf60 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 0}, {375, 690}}, owningView = <UIView: 0x7fb63fc06df0; frame = (0 88; 375 724); autoresize = W+H; layer = <CALayer: 0x600000024b80>>>
and then I did:
(lldb) po [[self firstItem] conformsToProtocol:@protocol(UILayoutSupport)]
error: cannot find protocol declaration for 'UILayoutSupport'
The debugger doesn't find the UILayoutSupport protocol declaration, which is weird...
In runtime, what happens is that the above condition resolves to NO, so the execution never falls in the line that decrements keyboardHeight, and that's why we still have that extra space in the screenshot.
I've tried replacing the fix with this, and it seems to be working fine:
- (void)_keyboardDidChangeVisible:(NSNotification *)notification {
...
if (notification.name == UIKeyboardWillShowNotification) {
if (@available(iOS 11.0, *)) {
UILayoutGuide *layoutGuide = [self layoutGuideItem];
if (layoutGuide != nil) {
keyboardHeight -= layoutGuide.owningView.safeAreaInsets.bottom;
}
}
}
...
}
- (UILayoutGuide *)layoutGuideItem {
if ([self.firstItem isKindOfClass:[UILayoutGuide class]]) {
return self.firstItem;
}
if ([self.secondItem isKindOfClass:[UILayoutGuide class]]) {
return self.secondItem;
}
return nil;
}Metadata
Metadata
Assignees
Labels
No labels
