textViewDidBeginEditing 由于缩放而未触发
我有一个 UIViewController 子类,它充当 UITextView 的委托。 我实现了 textViewDidBeginEditing 以显示“完成”按钮来关闭文本视图...一切都很好...除了当文本视图有文本并且不处于编辑模式时,如果用户在文本视图中按住手指会导致要使用放大镜缩放文本,键盘出现,但 textViewDidBeginEditing 不会触发。
我试图通过实现 UIScrollView 委托方法 viewForZoomingInScrollView 和scrollViewDidEndZooming 来解决这个问题,但我根本无法让这些方法为我触发。
我尝试使用minimumZoomScale和maximumZoomScale属性来禁用缩放...但无济于事。
此时,我不知道接下来要尝试什么,也不知道捕获 UIScrollView 委托方法的失败是否与我的主要问题有关。 我不确定我可以发布哪些有价值的代码... textViewDidBeginEditing 方法非常小,在正常情况下工作正常。 UITextView 委托分配是通过 Interface Builder 中与控制器(文件所有者)的连接进行的。
I have a UIViewController subclass that is acting as the delegate for a UITextView. I implemented textViewDidBeginEditing to display a 'Done' button to dismiss the text view... all is well... except that when the text view has text and is not in edit mode, if a user holds a finger in the text view causing the text to be zoomed with the magnifying glass, the keyboard appears but textViewDidBeginEditing does not fire.
I have tried to work around this by implementing the UIScrollView delegate methods viewForZoomingInScrollView and scrollViewDidEndZooming but I can't get those to fire for me at all.
I tried playing with the minimumZoomScale and maximumZoomScale properties to disable zooming... to no avail.
At this point I have no idea what to try next or if my failure catching the UIScrollView delegate methods is related to my main issue. I'm uncertain what code I could post that would be of value... the textViewDidBeginEditing method is very minimal and works fine in normal circumstances. The UITextView delegate assignment is made with a connection in Interface Builder to the controller (File Owner).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方法可能是注册键盘通知。 一旦你这样做了,你就会确切地知道键盘何时显示。
A workaround might be to register to the keyboard notifications. Once you do will know exactly when the keyboard is displayed.