带有“完成”的UITextView按钮*和*“返回”按钮键? [英] UITextView with "Done" button *and* "Return" key?

查看:192
本文介绍了带有“完成”的UITextView按钮*和*“返回”按钮键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iPhone应用程序中使用UITextView进行多行文本输入,并设置了返回键以显示完成。我还设置了返回键以禁用第一响应者状态,因此命中完成实际上会退出UITextView。但是,我还希望用户能够在UITextView中输入多行文本,即能够使用返回键。有没有什么方法可以在iPhone / iPad的用户界面上完成这项工作?

解决方案

这会耗费时间,但你可以创建你自己的键盘有这两个键(这可以通过为 UITextView 指定输入视图来完成)。 p>

另一种选择可能是在键盘上方放置一个可以解除键盘的按钮。您可以使用 UITextView 输入附件视图,它允许您创建位于键盘顶部的视图。 有关详细信息,请参阅此处(我知道这个文件适用于iPad,但它适用于所有iOS设备 - 也只是需要注意,这些都需要iOS 3.2或更高版本。)



这应该只需要要在iphone上完成,因为iPad键盘已经附带也可以关闭键盘按钮作为退货按钮。


I use a UITextView for multiline text entry in my iPhone app, and I have set the "Return" key to display "Done." I've also set up the return key to disable first responder status, so that hitting "done" actually exits the UITextView. However, I also want to enable users to be able to enter multiline text into the UITextView, i.e. to be able to use the "Return" key. Is there any way to make this work on the iPhone/iPad's UI?

解决方案

It'll be time consuming but you could create your own keyboard with both these keys (this can be done by specifiying the Input View for the UITextView ).

Another alternative could be having a button that sits just above the keyboard that would dismiss the keyboard. You can use the UITextView's Input Accessory View which allows you to create a view that sits on top of the keyboard. See here for more information (I'm aware this document is for iPad but it works for all iOS devices - also just to note, both these require iOS 3.2 or greater).

This should only need to be done on the iphone because the iPad keyboard already comes with a dismiss keyboard button as well as a return button.

这篇关于带有“完成”的UITextView按钮*和*“返回”按钮键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆