我创建了一个带有水平堆栈视图(标签、按钮、按钮)的简单列表。每个按钮都有自己的按钮动作,但是当我运行时,我可以看到点击一个按钮会打印两个动作。断点也出现在这两个操作中。她是我的代码
var body: some View {
NavigationView {
List {
ForEach(self.heroViewModel.heros, id: \.self) { hero in
Section(header: Text(hero.name)) {
ForEach(hero.movies, id: \.self) { movieName in
HStack {
Text(movieName)
.onTapGesture {
return
}.frame(width: 150, height: 30, alignment: .leading)
Spacer()
Button(action: {
print("Rate us")
}, label: {
Text("Rate us")
.background(Color.red)
}).padding()
Spacer()
Button(action: {
print("watch me")
}, label: {
Text("Watch")
.background(Color.red)
}).padding()
}
}
}
}
}.navigationBarTitle("Heros List")
}
}
Run Code Online (Sandbox Code Playgroud) 我创建列表并在其中添加 VStack 并在 VStack 中添加了一些视图。当我运行该项目时,我观察到 List 的滚动超出了安全区域。仅供参考,如果我删除 Frame 属性仍然是相同的结果。模拟器gif
struct ContentView : View {
var body: some View {
List(0..<5) { item in
HStack(alignment: VerticalAlignment.top, spacing: 5) {
Image(systemName: "photo")
VStack(alignment: HorizontalAlignment.leading, spacing: 10) {
Text("USA")
.font(.headline)
Text("This is an extremely long string that will never fit even the widest of Phones Excerpt From: Paul Hudson. “SwiftUI by Example”. Apple Books. ")
.lineLimit(nil)
.font(.subheadline)
}
}
}
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color.red)
.onAppear() {
print("on …Run Code Online (Sandbox Code Playgroud) 我知道这个问题被问了很多次,人们提出了很多解决方案。就我而言,我已经尝试了所有这些。我试过的是仅供参考:我不能使用 xcode 进行构建。 原因:我正在研究使用 GN 构建系统构建的所有 Chromium ios 代码。
有谁知道苹果还需要什么签名?最受欢迎的更多故障排除步骤。