gpt4 book ai didi

Implementing Dynamic Island support - Generic parameter 'Expanded' could not be inferred(实现动态孤岛支持-无法推断泛型参数‘Expanded’)

转载 作者:bug小助手 更新时间:2023-10-24 19:53:14 30 4
gpt4 key购买 nike



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

你想出来了吗?我收到了完全相同的错误

Same issue here

这里也有同样的问题

优秀答案推荐

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位有关。


更多回答

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com