Swiftui 导致崩溃的VStack内部地图

Swiftui 导致崩溃的VStack内部地图,swiftui,Swiftui,我有一个简单的地图视图: struct MapContainer: View { @EnvironmentObject var store: AppStore @State private var region: MKCoordinateRegion = Location.defaultRegion var events: [Event] { store.state.getEventsFromSearchResults() } func select(id

我有一个简单的
地图
视图:

struct MapContainer: View {
  @EnvironmentObject var store: AppStore
  @State private var region: MKCoordinateRegion = Location.defaultRegion
  var events: [Event] {
    store.state.getEventsFromSearchResults()
  }
  
  
  func select(id: UUID) {}
  
  
  var body: some View {
    Map(
      coordinateRegion: $region,
      interactionModes: .all,
      showsUserLocation: true,
      annotationItems: events,
      annotationContent: { event in
        MapAnnotation(coordinate: event.coordinates) {
          Image("MapMarker")
            .resizable()
            .scaledToFit()
            .frame(width: 24)
            .foregroundColor(
              event.id == store.state.searchState.tapped
                ? Color("Accent")
                : .black
            )
            .onTapGesture { select(id: event.id) }
        }
      }
    )
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .onAppear { region = store.state.searchState.near.region }
  }
}
我有一个使用上述容器的屏幕:

struct MapScreen: View {
  let height: CGFloat? = nil

  
  var body: some View {
    GeometryReader { geo2 in
      ZStack(alignment: .top) {
        VStack {
          MapContainer()
            .animation(.easeOut)
        }
        .frame(height: height != nil ? height : geo2.size.height / 2 + geo2.safeAreaInsets.top)
        

        VStack(spacing: 0) {
          VStack(spacing: 0) {
            HStack {
              Image(systemName: "minus")
                .font(.system(size: 40))
                .foregroundColor(Color("LightGray"))
                .padding(.vertical, 10)
            }
            .frame(maxWidth: .infinity)
            .contentShape(Rectangle())

            MapList()
          }
          .frame(height: 500)
          .background(Color.white.shadow(color: .gray, radius: 5, x: 0, y: 3))
        }
        .frame(maxHeight: .infinity, alignment: .bottom)
        .animation(.easeOut)


      }
      .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
    .edgesIgnoringSafeArea(.vertical)

    }
  }
}
当线程1:EXC\u BAD\u ACCESS(code=1,address=0x38)出现上述崩溃,但如果我将硬编码值分配给MapContainer,例如

MapContainer().frame(height: 400) 

然后一切正常。有人知道问题的原因吗?

你能在没有
AppStore
和其他不必要的代码的情况下创建一个应用程序吗?@aheze我更新了代码并删除了地图屏幕中所有多余的代码。它仍然崩溃。我觉得贴图需要有一个帧大小,但GeometryProxy没有及时将大小传递给贴图,因为如果我硬编码一个值,它工作得很好,或者如果从父对象传递一个几何体代理,那么它也工作得很好。