小编den*_*nho的帖子

SwiftUI - State change in UITextField causes the frameWidth to grow uncontrolled and ignore bounds/frame

I am using SwiftUI and bridge to UITextField (I need to assign firstResponder). I use the code from here: SwiftUI: How to make TextField become first responder?

The following code updates my @Binding var. This of course is intended behavior. The problem is that this causes the textField to ignore the frame/ bounds. It just expands and pushes other elements out of the view. Other parts of the view are also reliant on the @State.

func textFieldDidChangeSelection(_ textField: UITextField) { …
Run Code Online (Sandbox Code Playgroud)

uitextfield uikit swift swiftui uiviewrepresentable

19
推荐指数
1
解决办法
1370
查看次数

如何在 SwiftUI 中给 DatePicker 一个分钟的时间间隔

有谁知道如何给分钟 DatePicker 一个间隔?我试图只显示 15 的倍数(0、15、30、45)。这是否只能通过与 UIKit 接口来实现?

我相信它没有使用in: ...Date()零件,至少我想不出解决方案。这是我的片段:

DatePicker(
                "",
                selection: $selectedDate,
                /*in: ...Date(),*/
                displayedComponents: .hourAndMinute
            )
Run Code Online (Sandbox Code Playgroud)

非常感谢!

swift swiftui

8
推荐指数
1
解决办法
1482
查看次数

标签 统计

swift ×2

swiftui ×2

uikit ×1

uitextfield ×1

uiviewrepresentable ×1