adding .frame(height: 60) to each VStack works for me on macos 12.1 beta.
Post
Replies
Boosts
Views
Activity
Your code seems to work for me on macos 12.1beta, xcode 13.1,
targets ios 15 and MacCatalyst macos 12. Tested on real devices, iPad and Mac. Here is my test code:
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: ExploreView()) {
Label("Explore", systemImage: "rectangle.3.group")
}
NavigationLink(destination: Text("ListView")) { // <-- for testing
Label("Devices", systemImage: "list.bullet.below.rectangle")
}
}
.listStyle(.sidebar)
.navigationTitle("Orchard")
ExploreView()
}
}
}
// for testing
struct ExploreView: View {
var body: some View {
ZStack {
Color.pink.ignoresSafeArea()
Label("Devices", systemImage: "list.bullet.below.rectangle").foregroundColor(.white)
}
}
}
add .multilineTextAlignment(.leading) to your VStack or Text(...)
As a simple workaround, you could try this:
struct DecimalBindingView: View {
@State private var txt = ""
....
TextField("Input a number of type decimal…", text: $txt)
.onChange(of: txt) { val in
if let dec = Double(val) {
model.decimalQuantity = Decimal(dec)
}
}
...
}
Concur, you do not show enough of your code.
So I can only guess at your issues.
You use ContentView(orchard: Orchard[0])
in ContentView_Previews, note carefully the uppercase Orchard[0]. This is wrong,
Orchard is a type not an instance and not an array. It should at least be lowercase,
orchard[0]. The other error you get is because you have
"var orchard: Orchard " outside of any function or View or class. You cannot declare a variable without initialising, if it's not part of a class/struct etc..
could you show how you use these, and where/what line you get the error. In other words show the surrounding context of this code. Is this in a View, in a function, etc...?
you could try something simple like this:
struct ContentView: View {
@State private var buttons = 0
var body: some View {
// the button to add other buttons
Button(action: { buttons += 1 } ) {
Image(systemName: "plus.circle.fill").foregroundColor(.black)
}
// the added buttons
ForEach(0..<buttons, id: \.self) { i in
Button("button \(i)") {
}
}
}
}
you could try using .confirmationDialog("", isPresented: $showSheet) instead of the .sheet(...).
the picker options can be selected, you have to slide your finger or mouse, not just tap on it.
deleted comment again since there is no delete button
Not sure what you really mean with
"I am able to get upto periods, but nothing after that." My guess is, you want to access
the parameters of the period. If so, then try this:
Text(day.properties.periods[0].name)
Text(String(day.properties.periods[0].temperature))
In swift, it is fundamental to understand this.
comment deleted, because the formatting does not work.
show us the code you are using, maybe we "the community" can shed some light on your problems.
have you tried typing this in your browers search bar: "swift comparing dates". Did you get any responses?
you could use this one-liner:
editMode = editMode == .active ? .inactive : .active