Hi, after update to Swift6 and iOS 18 my code is not working anymore. This is code from documentation with onTapGesture (instead of primaryAction) and it's not working. OnTapGesture is not starting when user click.
Menu {
Button(action: {}) {
Label("Add to Reading List", systemImage: "eyeglasses")
}
Button(action: {}) {
Label("Add Bookmarks for All Tabs", systemImage: "book")
}
Button(action: {}) {
Label("Show All Bookmarks", systemImage: "books.vertical")
}
} label: {
Label("Add Bookmark", systemImage: "book")
} onTapGesture: {
print(" Print on tap gesture")
}
primaryAction isn't working either. I mean, primary action works but menu is not showing inside buttons.
Menu {
Button(action: {}) {
Label("Add to Reading List", systemImage: "eyeglasses")
}
Button(action: {}) {
Label("Add Bookmarks for All Tabs", systemImage: "book")
}
Button(action: {}) {
Label("Show All Bookmarks", systemImage: "books.vertical")
}
} label: {
Label("Add Bookmark", systemImage: "book")
} primaryAction: {
print("")
}
I also tried to overlay the menu, no effect.
ZStack {
Menu {
Button(action: {}) {
Label("Add to Reading List", systemImage: "eyeglasses")
}
Button(action: {}) {
Label("Add Bookmarks for All Tabs", systemImage: "book")
}
Button(action: {}) {
Label("Show All Bookmarks", systemImage: "books.vertical")
}
} label: {
Label("Add Bookmark", systemImage: "book")
}
Color.clear
.contentShape(Rectangle())
.onTapGesture {
print("Tap gesture recognized")
}
}
Please help. How to start action when user is clicking on menu?