当一个视图出现时,可刷新的指示器已经可见,而不需要在列表上执行滑动。当我向上滑动列表时,它会隐藏,然后可以以正确的方式执行拉刷新(它显示,执行操作和隐藏)。
我的检视:
struct OrdersView: View {
@EnvironmentObject private var tabBarStateManager: TabBarStateManager
@EnvironmentObject private var profileViewModel: ProfileViewModel
@StateObject private var ordersViewModel: OrdersViewModel = OrdersViewModel()
@Environment(\.dismiss) private var dismiss: DismissAction
var body: some View {
List {
ForEach(ordersViewModel.datesForOrdersViewListSections, id: \.self) { stringDate in
Section {
ForEach(ordersViewModel.getOrdersFor(date: stringDate), id: \.self) { order in
NavigationLink(destination: OrderDetailsView(order: order,
orderProductsList: ordersViewModel.getOrderProductsFor(order: order))
.environmentObject(ordersViewModel)) {
VStack(alignment: .leading, spacing: 20) {
HStack(spacing: 10) {
Text(order.id)
.font(.ssCallout)
Spacer()
Text(Date.getDayAndMonthFrom(date: order.orderDate))
.font(.ssTitle3)
.foregroundColor(.accentColor)
}
Text("$\(order.totalCost, specifier: "%.2f")")
.font(.ssTitle3)
.foregroundColor(.accentColor)
VStack(alignment: .leading) {
HStack {
Text(TexterifyManager.localisedString(key: .ordersView(.products)))
.font(.ssCallout)
Text("\(ordersViewModel.getOrderProductsFor(order: order).count)")
.font(.ssTitle3)
.foregroundColor(.accentColor)
}
HStack {
Text(TexterifyManager.localisedString(key: .ordersView(.orderStatus)))
.font(.ssCallout)
Text(order.status.rawValue)
.font(.ssTitle3)
.foregroundColor(.accentColor)
}
}
}
.padding(.vertical)
}
}
} header: {
Text(stringDate)
.font(.ssTitle1)
.foregroundColor(.accentColor)
}
}
}
.listStyle(.grouped)
.refreshable {
profileViewModel.fetchUserOrders {
ordersViewModel.userOrders = profileViewModel.userOrders
}
}
.navigationTitle(TexterifyManager.localisedString(key: .ordersView(.navigationTitle)))
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button {
dismiss()
} label: {
Image(systemName: "arrow.backward.circle.fill")
.resizable()
.frame(width: 30, height: 30)
.foregroundColor(.accentColor)
}
}
}
.onAppear {
ordersViewModel.userOrders = profileViewModel.userOrders
}
}
}
更改.refreshable
修改量顺序不能解决问题。更改.listStyle
也没有帮助。
问题只出现在iPhone 13 Pro Max(iOS 16.1)的物理设备上,相同版本的模拟器没有问题。
编辑:我发现只有当.navigationBarTitleDisplayMode
设置为.inline
而不是默认的.large
时,才会出现问题
截图:
1条答案
按热度按时间mqkwyuun1#
下面是一个示例实现,它并不完全适合您,因为您有复杂的结构,我无法重现。我希望您能从这个示例中得到一些好处: