如何在用户类型时垂直扩展Swiftui的文本框

发布于 2025-01-22 19:32:59 字数 648 浏览 3 评论 0原文

我所做的是为我编写的代码的小片段提供,用户通过文本框对问题回答。当我为iOS设备编码此过程时,用户写下了答案 - 文本框水平扩展。有什么方法可以更改此操作,因此文本框在编写时垂直增加,因此他们可以看到整个答案。牢记用户正在回答8/12分的问题(因为这是一个修订应用程序),需要更多空间。 (我已经删除了与文本框无关的所有代码,因此已经被删除了很多),

如果您可以帮助我了解如何最好地适应此问题,这真是太神奇了!

@State private var userAnswer: String = ""


var body: some View {
               
            

            VStack {
                TextField(
                    "Enter Answer",
                    text: $userAnswer )
                .disableAutocorrection(true)
            }
            .textFieldStyle(.roundedBorder)
            .padding(EdgeInsets(top: 10, leading: 15, bottom: 0, trailing: 15))

what I have done is provided a small snippet of a code I have written where the user responds to the question through the textbox. As I have coded this for iOS devices, as the user writes their answer - the textbox expands horizontally. Is there any way to change this so the text box increases vertically as they write, so they can see there entire answer. Bearing in mind the user is answering 8/12 mark questions (as this is a revision app), much more space is needed.
(I have removes all the code that isn't related to the text box and so a lot has been cut out)

If you could please help me to understand how to best accommodate this code for this issue that would be amazing!

@State private var userAnswer: String = ""


var body: some View {
               
            

            VStack {
                TextField(
                    "Enter Answer",
                    text: $userAnswer )
                .disableAutocorrection(true)
            }
            .textFieldStyle(.roundedBorder)
            .padding(EdgeInsets(top: 10, leading: 15, bottom: 0, trailing: 15))

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文