大家好,我正在使用"菜单"结构向用户展示可能的选择。
public struct Menu <Label, Content>: Display where Label: Display, Content: Display
一切看起来都与SwiftUI兼容,但我继续在控制台中收到警报,告诉我:
2021-09-30 20:55:40.032369+0200 [UILog] Called -[UIContextMenuInteraction updateVisibleMenuWithBlock:] while no context menu is visible. This won't do anything.
2021-09-30 20:55:41.344436+0200 [UILog] Called -[UIContextMenuInteraction updateVisibleMenuWithBlock:] while no context menu is visible. This won't do anything.
2021-09-30 20:55:41.414976+0200 [UICollectionViewRecursion] cv == 0x10401dc00 Disabling recursion trigger logging
2021-09-30 20:55:41.417708+0200 [UICollectionViewRecursion] cv == 0x10401dc00 Disabling recursion trigger logging
我做错了什么?
这是我的菜单代码
private var months: [Date] {
calendar.createDate(
interval: calendar.dateInterval(of: .year, for: Date())
matching: DateComponents(day: 1, hour: 0, minute: 0, second: 0)
)
}
var body: some View {
Menu("Options") {
ForEach(months, id:\.self) { month
Button("\(DateFormatter(format: "MMMM").string(from: month))"){
selectedDate = month }
}
}
}