【问题标题】:iOS widget always displaying placeholder on simulator or deviceiOS 小部件始终在模拟器或设备上显示占位符
【发布时间】:2022-12-21 01:35:24
【问题描述】:

我用(在 iOS 16 上)制作了一个非常基本的 iOS 小部件扩展:

struct TotoView: View 
    var body: some View {
        VStack {
            Text("Toto")
                .font(.headline)
        }
    }
} 

struct TotoWidget: Widget {
    var body: some WidgetConfiguration {
        IntentConfiguration(kind: "myKind", intent: ViewTodayIntent.self, provider: TimelineProvider()) { entry in
        TotoView(entry: entry)
    }
    .configurationDisplayName("Today work")
    .description("Show today work sessions")
    .supportedFamilies([.systemSmall, .systemMedium])
    }
}

在 SwiftUI Canvas 预览中,我可以看到“Toto”文本。

但是当我选择小部件目标并在模拟器中运行时,我只有占位符代替文本。知道为什么吗?请注意,不仅文本被占位符替换,而且 Image(systemName:)

我认为这个问题似乎与 IntentConfiguration 有关(因为 StaticConfiguration 一切正常)

我在 xCode 14 上。

【问题讨论】:

    标签: ios widgetkit


    【解决方案1】:

    在我的案例中,它有助于更​​改模拟器。该错误在我的案例中仍然存在于 iPhone 11 模拟器和真正的 iPhone 11 上。

    与其他模拟器一起使用效果很好。 您是否尝试过其他模拟器?

    可能是 iPhone 11 的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      • 2013-10-01
      • 2016-08-13
      • 2016-04-24
      • 1970-01-01
      相关资源
      最近更新 更多