Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone X keyboard appear showing extra space

Tags:

I have created a chat UI in which I have added a constraint for the tableView to the bottom of the screen. I am changing the constraint value by adding the height of the keyboard which is working fine in all the devices except iPhone X.

UI when key board is not visible:

enter image description here

Which is fine.

Problem is when keyboard appears blank space is visible in between the textView and the keyboard:

enter image description here

Do I have to try for a different approach for this or it can be resolved using constraints ?

like image 600
Amit Avatar asked Nov 14 '17 12:11

Amit


People also ask

How do I get rid of the space under my keyboard on my iPhone?

Just go to Settings, then go to General, press Keyboard and you will see a part saying “Predictive”. Just turn that off and the grey bar will disappear.

How do I get my iPhone keyboard back to normal?

Go to Settings > Accessibility > Keyboards, tap Full Keyboard Access, then turn on Full Keyboard Access.

Why is there a space on the bottom of my keyboard?

1 Solution @Mikeyr305 It looks like you have settings -> Display -> Navigation bar -> Show button to hide keyboard enabled. If you turn that off, the keyboard will sit at the bottom of the screen.

How do I resize my iPhone X keyboard?

Tap and hold on the emoji or globe icon on the keyboard. You will see three keyboard icons . Tap the left icon to shrink the keyboard to the left or the right icon to shrink the keyboard to the right. Tap the middle icon to return to the full-sized keyboard.


1 Answers

Try subtracting the height of the safe area's bottom inset when calculating the value for your constraint.

Here is a sample implementation which handles a UIKeyboardWillChangeFrame notification.

@objc private func keyboardWillChange(_ notification: Notification) {     guard let userInfo = (notification as Notification).userInfo, let value = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }     let newHeight: CGFloat     if #available(iOS 11.0, *) {         newHeight = value.cgRectValue.height - view.safeAreaInsets.bottom     } else {         newHeight = value.cgRectValue.height     }     myConstraint.value = newHeight } 
like image 69
nathangitter Avatar answered Oct 01 '22 07:10

nathangitter