skip to Main Content

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

menu output

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


  1. Chosen as BEST ANSWER

    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.


  2. Context menus on Mac Catalyst do not show images. From https://developer.apple.com/documentation/uikit/uiaction/3335177-image:

    Only the context menu system supports the display of an image, and only when the app is running in iOS.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search