Move my toolbar up or down based on keyboard and iOS 8 smart text view

I am developing a chat application that has a toolbar (with UITextView and other buttons) at the bottom of the chat screen, the same as whatsapp, which moves up and down depending on the visibility of the keyboard, which works fine before iOS 7.

I used UIKeyboardDidChangeFrameNotification , based on which I used the keyboard frame using the code below

  CGRect kKeyBoardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; 

and set the toolbar frame accordingly.

but it does not work on iOS 8 with predictive text. Any help was appreciated.

EDIT:

UIKeyboardDidChangeFrameNotification does not light up when the predictive text moves up or down.

Adding Pictures

Image with predictive textenter image description here

+7
iphone ios8 uiview keyboard
source share
1 answer

iOS 10, 9 up to 5

UIKeyboardDidChangeFrameNotification

Sent immediately after changing the keyboard frame.

The notification object is zero. The userInfo dictionary contains keyboard information. Use the keys described in Key Key Notification User Info Keys to get the location and size of the keyboard from the userInfo dictionary.

Tested on iPhone 6, iOS 10, 9, 8.4 (bundled, built, running, see the logs below).

The NSNotification dictionary shows the inverse of CGRect values ​​in UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey , and all 4 UIKeyboard__Notification are triggered when the appearance of the predicted accessory changes.

Swift 3

 func addObserver(forName: Notification.Name) { NotificationCenter.default.addObserver(forName: forName, object: nil, queue: OperationQueue.main) { (note:Notification!) -> Void in print("\(forName): \(note)") } } addObserver(forName: .UIKeyboardWillShow) addObserver(forName: .UIKeyboardDidShow) addObserver(forName: .UIKeyboardWillChangeFrame) addObserver(forName: .UIKeyboardDidChangeFrame) 

Turn Predictive ON

enter image description here

Magazine:

UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = {UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 258}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 554.5}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 538}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 442}, {375, 225}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 409}, {375, 258}}"; }

Turning Predictive OFF

enter image description here

Magazine:

UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = {UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 225}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 538}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 554.5}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 409}, {375, 258}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 442}, {375, 225}}"; }


β–Ί Find this solution on GitHub and more about Quick Recipes .

-one
source share

All Articles