Why do some views appear as a red no entry sign in widgets?
Background
Widget Views are static.
They don't support animation, navigation nor user interaction (with the exception of Link
). And they must be written in pure SwiftUI.
List of views that are not allowed in WidgetKit
Note that the list is not exhaustive, provided mostly with examples:
Interactive views (ones you can interact with, e.g., by touching them):
List
Form
ScrollView
TabView
Map
Picker
Slider
- and so on...
Animated views:
ProgressView
Navigation views (you can't use the standard navigation - for this you have
Link
):NavigationView
NavigationLink
UIKit Wrappers for UIKit Views/ViewControllers:
UIViewRepresentable
UIViewControllerRepresentable
Replacements
If you want to use any of the above views, e.g. an interactive view like List
, you need to create it out of non-interactive views - here VStack
+ ForEach
.
How to prevent iOS 14 Widget opening app and react to callback
Can I programmatically say "prevent opening app", when tapping on one of these buttons I've created in my Widget?
No, this is simply not possible (at least so far, in iOS 14).
By default whenever you tap on a Widget, the App will be opened. You can only specify deep links etc. but they'll always open the app.
I already read [...] that iOS 14 Widgets are NOT interactive
In this context interactive means that you can't touch/drag/interact with a Widget view like you'd normally do with a view in your main app (see Why do some views appear as a red no entry sign in widgets?).
Also, when you click on a Widget, you don't really interact with its view - you just open the app. As of iOS 14 you can't change it.
Related Topics
How to Add Text, Shape and Signature in Photo Markup with Pencil Kit
Codesign Returned Errsecinternalcomponent in High Sierra
<Googlemaps/Googlemaps.H> File Not Found Google Maps Sdk for iOS
Uipickerview: Nsattributedstring Not Available in iOS 7
Can an iOS App Switch the Device to Silent Mode
Incorrect Height Calculation with Draggesture() in Swiftui
How to Convert Video (In Gallery) to Nsdata? in Swift
Swrevealviewcontroller - Rightviewcontroller
Hiding Cancel Button on Search Bar in Uisearchcontroller
Change Tabview Color Based on Which Tab Is Selected -Swiftui
Send an Email from My App Without Using Mfmailcomposeviewcontroller
Swiftui: Animation Inside Navigationview