Traditional Culture Encyclopedia - Weather inquiry - iOS 14-WidgetKit
iOS 14-WidgetKit
Widget is hosted in the App, so the App function must be implemented first.
You can enjoy the data both online and locally. Local data * * * can be enjoyed through the App group, which is a way of * * * sharing data between apps after iOS 8, and data * * * can be shared only by simple configuration.
After the configuration is completed, data sharing between App and Widget can be realized through UserDefaults or FileManager. Take UserDefaults as an example here, because SwiftUI provides @AppStorage to simplify the operation.
Regardless of the configuration, you need to provide the following.
The data model required to render widgets needs to conform to the TimelineEntry protocol.
Follow the TimelineProvider protocol and tell WidgetKit when to render and refresh widgets. The following two methods need to be implemented:
Placeholder view is a standard SwiftUI view, which will be displayed when it is first displayed or an error occurs.
The content displayed by widgets on the screen needs to be built with SwiftUI, and widgets with different sizes can set different views.
You can only click, and clicking will open the App. You can also configure when passing. WidgetURL(myDeeplink) method can also trigger different deep links by using links.
Small tool box
- Related articles
- Is there any Korean runningman episode that is fun? Please recommend it.
- Leave classical Chinese in the New Year.
- How long is the tour in Moscow? When is the best time to visit Moscow?
- Translate a sentence in English. . . The weather is getting warmer and warmer. Can't the weather here say that the weather can only use it as the subject?
- Which city does Nanchong belong to?
- When is the best season to get married?
- 1 10, 1 12, 1 19, 120, 122, what are the numbers respectively? What other special numbers are there?
- Pokemon diamond Ibrahim
- Which is more important, weather, physics or geography?
- When did the temperature drop in Changsha 202 1 summer?