textViewDidBeginEditing 由于缩放而未触发

发布于 2024-07-25 00:50:56 字数 563 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦境 2024-08-01 00:50:56

解决方法可能是注册键盘通知。 一旦你这样做了,你就会确切地知道键盘何时显示。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationShow:) name:UIKeyboardWillShowNotification object:nil];  

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationHide:) name:UIKeyboardWillHideNotification object:nil];  

A workaround might be to register to the keyboard notifications. Once you do will know exactly when the keyboard is displayed.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationShow:) name:UIKeyboardWillShowNotification object:nil];  

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardNotificationHide:) name:UIKeyboardWillHideNotification object:nil];  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文