Keyboard events called before UITextView delegate events

。_饼干妹妹 提交于 2021-02-10 05:30:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!