在 UITextField 中换行文本?
有谁知道如何在 UITextField
中换行文本?我在 Xcode 中为我的 iPhone 项目使用 Cocoa/Objective-C,但我似乎找不到方法来做到这一点......
Does anyone know how to wrap text in a UITextField
? I am using Cocoa/Objective-C in Xcode for my iPhone project, and I can not seem to find a way to do this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UITextField
仅适用于单行文本。如果您想要多行文本,那么您必须使用UITextView
类代替。值得注意的是
UITextView
继承自UIScrollView
,因此如果您不想滚动,您可能需要坚持使用UITextField
并放置文本在一行上...我曾经尝试对UITextView
进行子类化,使其像多行UITextField
一样,但是UIScrollView
让这个任务变成了一场噩梦——最后我只是重新使用一个简单的 UITextField。UITextField
is meant for single-line text only. If you want multiple lines of text, then you'll have to use theUITextView
class instead.It's worth noting that
UITextView
inherits fromUIScrollView
, so if you don't want scrolling, you may want to stick with theUITextField
and put up with the text being on one line... I once tried to subclassUITextView
to make it like a multiple-lineUITextField
, but theUIScrollView
made the task a nightmare—in the end I just went back to using a simpleUITextField
.