Post

Replies

Boosts

Views

Activity

Reply to Navigating programmatically in SwiftUI
Hi there, in this instance I would consider this to be a very adequate solution. It of course gets more complicated when you need multiple NavigationLinks, but as long as you only use a few this a reliable and simple solution. You could even remove the .hidden() modifier and just wrap the Link in an HStack. Take care David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Sending variable between views & Classes
Hi there, you could just change the value inside the class using: class WeatherViewModel: ObservableObject {     @Published var city : String = "city name changed by view"     func getCityData(){         print("called")     } } struct WeatherView: View {     @ObservedObject var data = WeatherViewModel()     var body: some View{         VStack{             Button(action: {                 data.city = "city name"             }){                 Text("Change City")             }         }     } } Does this help you? Take care David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to XCode + SwiftUI+ EnvironmentObject not working on iPad
Hi, It looks like you are passing the return Value from the GetValue() function into the Text Element. Try this:  Text(sharedObj.CustomString)         Button(action: {             sharedObj.Update(input: "NewValue")         }){             Text("Update")         } When you call the update function the Custom String is automatically updated in the Text Element. Take care, David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to SwiftUI MapKit Callouts
Hi, sadly the SwiftUI MapKit implementation is very poor at the moment. You can wrap the EventMapAnnotation in a Button(action: {}), this at least gives you the option of calling a function that will then trigger some action. Take care, David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to SwiftUI Navigation link issue
Hi, I would put the ForEach in either a List, or a form. Then you should change the row to something like this:   NavigationLink(destination: Text("Destination")){         VStack{             Text("Content")         }     } The NavigationLink should be the first thing in the row to work probably. Take care, David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to How to create Tappable Button in swiftui For Widgets
Hi, Widgets will always launch the app when they are tapped, so there is no way to only add an action to the widget. Depending on the Widget Size you have the option of using Tap targets. The small Widget only has one big button, itself. The large Widget has a few targets that can perform different actions by using different URLs, but they also launch the app. Take care, David
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21