所以我在运行我设置的游戏应用程序时收到此错误:
\n当出现更多相同卡牌时的游戏屏幕图像(游戏中的所有卡牌都应该是唯一的)
\nForEach<Range<Int>, Int, ModifiedContent<_ConditionalContent<_ConditionalContent<_ConditionalContent<_ConditionalContent\n<ZStack<TupleView<(_ShapeView<Squiggle, ForegroundStyle>, \n_StrokedShape<Squiggle>)>>, ZStack<TupleView<(ModifiedContent<_StrokedShape<StripedRect>, \n_ClipEffect<Squiggle>>, _StrokedShape<Squiggle>)>>>, _StrokedShape<Squiggle>>, \n_ConditionalContent<_ConditionalContent<ZStack<TupleView<(_ShapeView<Capsule, ForegroundStyle>, _StrokedShape<Capsule>)>>, \nZStack<TupleView<(ModifiedContent<_StrokedShape<StripedRect>, _ClipEffect<Capsule>>, \n_StrokedShape<Capsule>)>>>, _StrokedShape<Capsule>>>, _ConditionalContent<_ConditionalContent<ZStack<TupleView<(_ShapeView<Diamond, \nForegroundStyle>, _StrokedShape<Diamond>)>>, ZStack<TupleView<(ModifiedContent<_StrokedShape<StripedRect>, _ClipEffect<Diamond>>, \n_StrokedShape<Diamond>)>>>, _StrokedShape<Diamond>>>,\n _FrameLayout>> count (2) != its initial count (1). `ForEach(_:content:)`\n should only be used for *constant* data. Instead conform data to `Identifiable` \nor use `ForEach(_:id:content:)` and provide an explicit `id`!\nRun Code Online (Sandbox Code Playgroud)\n视图本身下方的卡片模型似乎没有改变。除了卡片上的形状数量之外,所有内容都保持不变。因此,仅当底层模型正确匹配时,显示错误的卡片才会匹配,并且不会像视图中显示的那样匹配。
\n仅当我获得正确的设置并按“显示另外三张卡片”或当我显示的卡片多于可见卡片然后在屏幕上上下滚动时,才会出现该错误。
\n应用程序不会因错误而停止,但每张卡上的 numberOfShapes 会动态变化(如上面的屏幕截图所示)。(当我滚动到屏幕顶部然后滚动到底部时,这一点最为清晰,并且某些卡片上的形状数量每次都会发生变化)
\n所以我认为问题可能出在卡片视图中:
\nimport SwiftUI\n\nstruct CardView: View {\n \n var card: Model.Card\n \n var …Run Code Online (Sandbox Code Playgroud)