I'm trying to get a numeric field updated so I'm using a TextField with the formatter: parameter set. It formats the number into the entry field just fine, but does not update the bound value when edited. The TextField works fine (on Strings) without the formatter specified. Is this a bug or am I missing something?
UPDATE: As of Xcode 11 beta 3 it kind of works. Now if you edit the numeric TextField, the bound value is updated after …
在Xcode beta 4中,使用PresentationLink会给出以下警告:“不推荐使用'PresentationLink':请改用.sheet修饰符。”
我假设它们的意思是某种形式的
func sheet<Content>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, content: @escaping () -> Content) -> some View where Content : View
Run Code Online (Sandbox Code Playgroud)
但我不确定如何切换到此模式-特别是,这种isPresented说法使我感到困惑。我知道有一个名为isPresented的Environment变量,但是对于当前View来说,这不是吗,不是要呈现的View吗?
我对此最感兴趣,因为我希望这能解决PresentationLinks仅工作一次的问题(请参阅swiftUI PresentaionLink第二次不工作)
现在不赞成使用PresentationLink的人可以提供一个简单的示例来显示视图吗?例如,将以下内容转换为使用.sheet修饰符:
NavigationView {
List {
PresentationLink(destination: Text("Destination View")) {
Text("Source View")
}
}
}
Run Code Online (Sandbox Code Playgroud) swiftui ×2