在 UITextField 中换行文本?

发布于 2024-08-18 02:51:25 字数 111 浏览 7 评论 0原文

有谁知道如何在 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 技术交流群。

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

发布评论

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

评论(1

狠疯拽 2024-08-25 02:51:25

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 the UITextView class instead.

It's worth noting that UITextView inherits from UIScrollView, so if you don't want scrolling, you may want to stick with the UITextField and put up with the text being on one line... I once tried to subclass UITextView to make it like a multiple-line UITextField, but the UIScrollView made the task a nightmare—in the end I just went back to using a simple UITextField.

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