Post

Replies

Boosts

Views

Activity

Reply to WidgetKit configuration display name?
I have an idea... I honestly don't know if it will work but! You can create App Group between your iOS app and Extension, then using UserDefaults for groups you can "share" the display name and description. I would give this a try. In my configuration I am also using UserDefaults to get certain data from the main app. You could say: var body : some View{ Button(action: {buttonPress(title: "newTitle")}){ Text("change widget title") } } func buttonPress(title: String){ UserDefaults(suiteName: "yourAppGroup")?.setValue(title ,forKey: "widgetTitle") print("title updated") } and in your widget extension you just get the "widgetTitle" value from User Defaults.
Sep ’20
Reply to WidgetKit and Background App Refresh
hi there, well does the information in the widget change without the user doing (adding, editing) anything. To put it in other words: Should the content in the widget change without the user opening the app? Because if the Information only changes when the user for example adds a new item to a list you can't really keep the widget "more" up to date. In my App, the widget only needs to be updated when the content of a list changes...
Sep ’20
Reply to WidgetKit macOS widgets release without app
hi there, I understand what your goal is 😉. But to be honest I don't think Apple will allow "widget only" apps mainly for the reason that in Apples guidelines it says: A widget elevates key content from your app and displays it where people can see it at a glance on iPhone, iPad, and Mac. Useful and delightful, widgets can also help people personalize their iPhone Home screens in unique ways. So Apple sees widgets as a way of displaying relevant data from your app and not that the widget have a mind of their own. You could use the main app to customise the widget, so that you don't have to use a static screen🙃
Sep ’20
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
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
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
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
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
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
Feb ’21