文本输入框像iPhone上的短信应用程序 [英] Text input box like the SMS app on the iPhone

查看:113
本文介绍了文本输入框像iPhone上的短信应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可怕的时间,试图获得一个输入框,像短信应用程序中的一个。



任何人都可以提供一些指导,了解如何构建其中一个,并使它看起来不错?我需要一个输入框,它的形状很好像UITextfield,但会在输入时垂直伸展。



我假设我需要计算文本的宽度,并且当文本单词换行时垂直拉伸叠加图像帧。



更新:



我每天工作一个星期,我已经放弃了UITextView。我可以得到它伸展正确,但后退时,Textview高度收缩太多,当一条线。当我继续后退它自己纠正。例如,当我在第4行,退格直到第3行时,它显示这种行为。然后,当我继续后退,它纠正,直到我到达第2行的结束。然后它纠正自己,....等。 / p>

我决定尝试子类化UITextField,但我甚至不能让它显示在我指定的框架大小。 150,150,150,150。

解决方案

Three20



从Three20 README:


TTTextEditor是一个UITextView,它可以自动增加
的高度,和
类型一样。我用它在Facebook Chat中输入消息
,它的行为类似于Apple的SMS
应用程序中的编辑器



I am having a terrible time trying to get an input box like the one in the SMS app.

Can anyone offer some guidance on how to build one of these and make it look good? I need an input box that is shaped nicely like the UITextfield but will stretch vertically when typing.

I assume that I need to calculate width of the text and stretch the overlay image frame vertically when the text word wraps. The closest I have come does stretch but the cursor bounces all around when nearing the boundaries.

UPDATE:

I have worked on this everyday for a week and I have about given up on the UITextView. I can get it to stretch properly but when backspacing, the Textview height shrinks too much when going up a line. As I continue backspacing it corrects itself. For example, it displays this behavior when I am on line 4 and backspace up to line 3. Then as I continue backspacing, it corrects until I get to the end of line 2. Then it corrects itself,.... etc.

I decided to try to subclass UITextField but I can't even get it to display in the Frame size that I specify. 150,150,150,150.

解决方案

Three20 project has a control that should do this for you.

From the Three20 README:

TTTextEditor is a UITextView which can grow in height automatically as you type. I use this for entering messages in Facebook Chat, and it behaves similarly to the editor in Apple's SMS app.

这篇关于文本输入框像iPhone上的短信应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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