我正在 SwiftUI 中开发一个跨平台应用程序。在 iPhone / iPad 上,此代码在 MacOS 上运行良好,而不是当我插入 NavigationLink 时,ForecastCardView 被完全切断。当我删除 NavigationLink 时,一切都会正确呈现。
使用导航链接
var FullSection: some View {
LazyVGrid(columns: homeConfigurationUI.columns, alignment: .center, spacing: 20) {
NavigationLink(destination: Text("test")) {
ForecastCardView(viewModel: ForecastCardViewModel.initForTest())
}.frame(width: 300, height: 300, alignment: .center)
}
.border(Color.yellow)
.frame(minWidth: 300, idealWidth: 400, maxWidth: 600, minHeight: 0, idealHeight: 500, maxHeight: .infinity, alignment: .center)
}
没有导航链接
var FullSection: some View {
LazyVGrid(columns: homeConfigurationUI.columns, alignment: .center, spacing: 20) {
ForecastCardView(viewModel: ForecastCardViewModel.initForTest())
}
.border(Color.yellow)
.frame(minWidth: 300, idealWidth: 400, maxWidth: 600, minHeight: 0, idealHeight: 500, maxHeight: .infinity, alignment: .center)
}
一切都在 ScrollView 中,我尝试将 List 插入 VStack,但没有结果。我试图在每个组件上放置一个静态框架,但无事可做。