I'm following Displaying live data with Live Activities and adding support for the Dynamic Island in an app with an existing widgets extension. However, I'm unable too get it to build
我将使用Live Actitions显示实时数据,并在一个应用程序中添加对Dynamic Island的支持,该应用程序具有现有的小部件扩展。然而,我也不能把它造出来
import SwiftUI
import WidgetKit
@main
struct PizzaDeliveryActivityWidget: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: PizzaDeliveryAttributes.self) { context in
// Create the presentation that appears on the Lock Screen and as a
// banner on the Home Screen of devices that don't support the
// Dynamic Island.
// ...
} dynamicIsland: { context in
// Create the presentations that appear in the Dynamic Island.
// ...
}
}
}
as I get the errors
当我收到错误信息时
Generic parameter 'Expanded' could not be inferred
and
和
Result builder 'DynamicIslandExpandedContentBuilder' does not implement any 'buildBlock' or a combination of 'buildPartialBlock(first:)' and 'buildPartialBlock(accumulated:next:)' with sufficient availability for this call site
This is even if I supply a dynamicIsland
closure of
即使我提供了DynamicIsland关闭的
DynamicIsland {
EmptyView()
} compactLeading: {
EmptyView()
} compactTrailing: {
EmptyView()
} minimal: {
EmptyView()
}
What am I missing? My project's minimum deployment target is iOS 16.1.
我遗漏了什么?我的项目的最低部署目标是iOS 16.1。
更多回答
Well you only have comments in your code... You should have at least a DynamicIslandExpandedRegion
in your DynamicIsland
. Did you read the whole guide you linked? It shows how to do this further down the page.
您的代码中只有注释……您的DynamicIsland中应该至少有一个DynamicIslandExpandedRegion。你看了你链接的整个指南了吗?它展示了如何在页面下方进一步执行此操作。
Did you figure this out? I'm getting the exact same error
你想出来了吗?我收到了完全相同的错误
优秀答案推荐
I fixed my issue by adding the following above the widget declaration
@available(iOS 16.2, *)
我通过在小部件声明@Available(iOS 16.2,*)上面添加以下内容修复了我的问题
(Yes 16.2), it has something to do with the context.isStale bit.
(是16.2),它与Conext.isStale位有关。
更多回答
我是一名优秀的程序员,十分优秀!