Post

Replies

Boosts

Views

Activity

Reply to Loading View on API call
Make your getHomeItems() with a closure when done, and try something like this: .onAppear { self.showLoading = true DispatchQueue.main.async { store.getHomeItems() { _ in // <--- here self.showloading = false // <--- here } } ... }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to SwiftUI sidebar not behaving as intended
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) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to Data struct not working
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..
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Add Button
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)") { } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Loading View on API call
Make your getHomeItems() with a closure when done, and try something like this: .onAppear { self.showLoading = true DispatchQueue.main.async { store.getHomeItems() { _ in // <--- here self.showloading = false // <--- here } } ... }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to LazyVGrid rows no longer filling available height in Monterey
adding .frame(height: 60) to each VStack works for me on macos 12.1 beta.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to SwiftUI sidebar not behaving as intended
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) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Bug in VStack alignment in button in iOS15.
add .multilineTextAlignment(.leading) to your VStack or Text(...)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to TextField with NumberFormatter, bound to Decimal property with Xcode > 13 beta 2.
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) } } ... }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Data struct not working
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..
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Data struct not working
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...?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Add Button
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)") { } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to SwiftUI sheet size control on iPad
you could try using .confirmationDialog("", isPresented: $showSheet) instead of the .sheet(...).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to "onTapGesture" interferes with segmented picker
the picker options can be selected, you have to slide your finger or mouse, not just tap on it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Share Sheet in Child
deleted comment again since there is no delete button
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How can I go about accessing the Periods portion of NOAA Api response?
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Problems with NavigationView and NavigationLink
comment deleted, because the formatting does not work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Problems with NavigationView and NavigationLink
show us the code you are using, maybe we "the community" can shed some light on your problems.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Date in Swift printed is wrong
have you tried typing this in your browers search bar: "swift comparing dates". Did you get any responses?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21