键盘可见时,将输入附件视图添加到UITextField

编程入门 行业动态 更新时间:2024-10-10 03:24:09
本文介绍了键盘可见时,将输入附件视图添加到UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将输入附件视图添加到 UITextField ,而它是第一个响应者,即显示键盘。显然,在此状态下将 UIView 分配给 inputAccessoryView 属性不会显示此视图。我必须首先关闭键盘并重新选择 UITextField 。

I would like to add an input accessory view to a UITextField while it is the first responder, i.e. showing the keyboard. Apparently, assigning a UIView to the inputAccessoryView property in this state doesn't display this view. I have to first dismiss the keyboard and re-select the UITextField.

有没有办法添加输入附件视图没有解雇和重新选择?

Is there a way to add an input accessory view without dismissing and re-selecting?

推荐答案

如果可能的话只分配 inputAccessoryView 一次。如果您需要进行自定义,并且只能确定在成为第一个响应者之前已经很晚,那么我仍然只会分配一次。但是在 UITextFieldDelegate 方法中自定义 inputAccessoryView 的子视图 textFieldShouldBeginEditing:。像这样:

If possible only assign the inputAccessoryView once. If you need it to be customized, and can only determine how very late just before becoming the first responder, then I would still only assign it once. But customize the subviews of the inputAccessoryView in the UITextFieldDelegate method textFieldShouldBeginEditing:. Like so:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { [self setupInputAccessoryViewForTextField:textField]; return YES; }

更多推荐

键盘可见时,将输入附件视图添加到UITextField

本文发布于:2023-11-09 04:05:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   附件   键盘   UITextField

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!