问题
I have a UITableView
with UITextViews
and UITextFields
on it's cells. As obvious the keyboard overlaps the lower cells and you cannot see what you are typing.
So I want to scroll the tableview
to get the field visible.
I wrote the code the iOS
docs recommended: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
BUT the keyboard event callback keyboardWillShow:
is called before the UITextView
edit callback textViewDidBeginEditing:
. So I cannot set the active textview when I try to calculate the scrolling I need to make the active textview visible.
Anyone knows a solution for this?
回答1:
Take the code out of keyboardWillShow:
and add it into keyboardDidShow:
This is obviously called after it has been presented ...
If you're using notifications you need to add:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
来源:https://stackoverflow.com/questions/22389114/keyboard-events-called-before-uitextview-delegate-events