I am having issues with UIContextMenus in iOS 16 and Catalyst. The following code displays the menus, but not the images. I’m confused.
extension CapoButton: UIContextMenuInteractionDelegate {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
return UIMenu(title: "test", image: UIImage(systemName: "star.fill"), identifier: .capoButtonMenu ,options: UIMenu.Options.displayInline, children: [
UIAction(title: "subtest 1", image: UIImage(systemName: "star.circle")!) {_ in
print("fred 1")
},
UIAction(title: "subtest 2", image: UIImage(systemName: "star")!) {_ in
print("fred 2")
}
])
}
}
}
The result is
Neither of the images in the UIActions display nor does he title/image of the primary menu. I have tried the UImage with and w/o the unwrap (!).
2
Answers
Finding that context menus in catalyst are not predictable. They work for some UIView type and not others. Will likely need to create my own popups.
Context menus on Mac Catalyst do not show images. From https://developer.apple.com/documentation/uikit/uiaction/3335177-image: