Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@between40and2
Last active December 19, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save between40and2/6017291 to your computer and use it in GitHub Desktop.
Save between40and2/6017291 to your computer and use it in GitHub Desktop.
After 3 years of iOS development practice, finally I have chance to fully work with the soft keyboard. I found the Apple official docs is far from enough to deal with every cases of iOS soft keyboard. Then online 3rd party docs are helpful but not complete either. I can understand it since everyone is busy, very few people to write a complete guide for any specific topics.
Then I come to this. I have to do trial and error to grasp this piece of knowledge. One problem I was facing is when device is in landscape, you cannot use keyboard's height to adjust textview/tableview's contentInsets, since the height actually seems as its "width". UIWindow is mounted always in portrait mode, and keyboard frame goes with it. When device and UI is in landscape, the keyboard frame is still measured as it is in portrait. The solution:
CGRect frameEnd = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
frameEnd = [self.view convertRect: frameEnd fromView: nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment