isa*_*dev 6 xcode ios swift swiftui
我有一个带有导航视图的简单列表,其中导航视图在滚动时与列表重叠。
这是代码
struct MedicalDashboard: View {
let menuItemData = MenuItemList()
var body: some View {
NavigationView {
List(menuItemData.items, id: \.id) { item in
MenuItemRow(menuItem: item)
}
.listStyle(.insetGrouped)
.navigationTitle("Dashboard")
.navigationBarItems(trailing:
Button(action: {
// TODO: - Pop up a sheet for the settings page.
print("User icon pressed...")
}) {
Image(systemName: "person.crop.circle").imageScale(.large)
}
)
.padding(.top)
}
}
Run Code Online (Sandbox Code Playgroud)
}
在 Xcode 13.4 上,除了缺少}、没有.padding(.top)和自定义 之外,List一切对我来说都很有魅力。
问题可能来自MenuItemList().
我仍然通过替换.navigationBarItems和添加工作表来更新您的代码:
struct MedicalDashboard: View {
@State private var showSheet = false
var body: some View {
NavigationView {
List { // Custom list
Text("Hello")
Text("Salut")
}
.listStyle(.insetGrouped)
.navigationTitle("Dashboard")
.toolbar() { // .navigationBarItems will be deprecated
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
showSheet.toggle()
print("User icon pressed.")
}, label: {
Image(systemName: "person.crop.circle")
})
.sheet(isPresented: $showSheet) { /* SettingsView() */ }
}
}
}
} // New
}
Run Code Online (Sandbox Code Playgroud)
编辑您的帖子并向我们展示MenuItemList()。
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |