如何使用选择器将内容添加到我的 Textview

发布于 2024-12-22 08:51:43 字数 97 浏览 0 评论 0原文

我想添加一个下拉框,让用户从我的 iPhone 应用程序中的一些预定义值中进行选择,但由于这是不可能的,所以我想我应该使用选择器。如何让文本视图提示选择器值以使用选择填充文本视图?

I wanted to add a drop down box to get the user to select from some pre-defined values in my iPhone app but as that's not possible I thought I would use a picker instead. How do I get the textview to prompt a picker value to populate the Textview with the selection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

烟沫凡尘 2024-12-29 08:51:43

您可以将 UIPickerView 设置为 UITextViewinputView 并侦听选择器的更改并调整 UITextView< 的内容/code> 相应地。不过,您可能仍然会看到一个光标。

inputView 本质上取代了键盘。然而,外部键盘仍然可以在 UITextView 中输入普通文本,除非您通过委托方法阻止这种情况

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text

You could set a UIPickerView as the inputView to the UITextView and listen for changes to the picker and adjust the content of the UITextView accordingly. You will probably still see a cursor though.

The inputView essentially replaces the keyBoard. External keyboard can however still enter normal text into the UITextView unless you prevent this via the delegate method

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
握住我的手 2024-12-29 08:51:43

我认为你必须禁用 Textview 的属性编辑

I think you have to disable the property editing of Textview

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文