I've created a project in xcode 12 and added a Widget Extension target. The target is created and I'm left with a simple widget that shows the time. The preview of the widget works as expected and the widget is shown as expected in the simulator. But if I change the view to use List
instead of Text
, like this:
struct SimpleWidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
List {
Text("Something")
}
}
}
The preview and the simulator both show a red No Entry sign on a yellow background:
I've tried putting the List
inside a VStack
and using a dynamic list without any success. I can't find any documentation about List
being prohibited in a widget. I've tried restarting xcode and the simulator, cleaning and rebuilding. I'm using xcode 12.0 beta 3.
~I also get this issue trying to use a UIView
wrapped in UIViewRepresentable
. The view is a LineChartView
from the Charts library.~ Edit: according to this post on the Apple developer forums it isn't possible to use UIKit views in a WidgetKit widget.
Does anyone know how I can use a List
in a widget? Any help much appreciated. Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…