Thanks for your reply.
I tried that but that changes the background in every view that has a list in it. and I only want it in one view.
Post
Replies
Boosts
Views
Activity
hi there, thanks for your speedy response😁.
yeah I am trying to submit it to TestFlight. so do you mean that there is no way to upload it to TestFlight? I want to test the new iOS14 widgets and a few other changes...
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.
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...
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🙃
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
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
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
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
Hi,
If your Array contains actual Dates and not date strings you can use this:
var sorted = array.sort({$0.compare($1) == .OrderedDescending})
Take care,
David
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
Hi,
Form only has one style, which is the InsetGrouped Style. You can change the Form to a List and apply a ListStyle(). Keep in Mind that this will change the appearance of the picker, so maybe use a .pickerStyle().
Take care,
David
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
Hi,
NavigationViews are, depending on device and orientation, displayed in a few different ways. To achieve what you want you need to modify the NavigationView using:
NavigationView{
Text("View")
}.navigationViewStyle(StackNavigationViewStyle())
Take care,
David
The same thing is now happening with the current Xcode Version and the M1 MacBook Pro. I had to install the 12.5 beta to get it running reliably again...