'How to show pull down button menu in IOS 14 swift

I created a pull down button like below

@IBOutlet weak var pullDownButton: UIButton!

Then I called a method from viewDidLoad() to configure pull down menu reference

func setupMenu() {
    let add = UIAction(title: "Add", image: UIImage(systemName: "plus")) { _ in
        self.showToast(message: "Add", seconds: 1.0)
    }
    
    let edit = UIAction(title: "Edit", image: UIImage(systemName: "pencil")) { _ in
        self.showToast(message: "Edit", seconds: 1.0)
    }
    
    let delete = UIAction(title: "Delete", image: UIImage(systemName: "minus")) { _ in
        self.showToast(message: "Delete", seconds: 1.0)
    }
    
    let menu = UIMenu(title: "Menu", children: [add, edit, delete])
    pullDownButton.menu = menu
    pullDownButton.showsMenuAsPrimaryAction = true
}

But I am unable to show the pull down menu upon long press or simple press.

Is there any way to show the pull down menu



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source