Popovers icon indicating copy to clipboard operation
Popovers copied to clipboard

Unable to use a MenuButton twice in a row.

Open blackboxembedded opened this issue 1 year ago • 3 comments

I'm having an issue where I'm unable to use a MenuButton twice in a row. Below is a simplified example. You will only see one print if you tap "Test1" more than once in a row. Oddly If you tap "Test2" after, then "Test1" it will print once again.

import UIKit
import Popovers
class TestController: UIViewController {
    
    private var menuBtn: UIButton?
    lazy var menu = Templates.UIKitMenu(sourceView: menuBtn!) {
		Templates.MenuButton(title: "Test1", systemImage: nil) { print("Test 1")}
		Templates.MenuButton(title: "Test2", systemImage: nil) { print("Test 2")}
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        menuBtn = UIButton()
        menuBtn!.setImage(UIImage(named: "Menu")?.withRenderingMode(.alwaysTemplate), for: .normal)
        let menuButton = UIBarButtonItem(customView: menuBtn!)
        let menuButtonWidth = menuButton.customView?.widthAnchor.constraint(equalToConstant: 30)
        menuButtonWidth?.isActive = true
        let menuButtonHeight = menuButton.customView?.heightAnchor.constraint(equalToConstant: 30)
        menuButtonHeight?.isActive = true
        self.navigationItem.rightBarButtonItems = [menuButton]
        
        _ = menu /// Create the menu.
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    }
}

blackboxembedded avatar Mar 12 '23 00:03 blackboxembedded