Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use a MenuButton twice in a row. #75

Open
blackboxembedded opened this issue Mar 12, 2023 · 3 comments
Open

Unable to use a MenuButton twice in a row. #75

blackboxembedded opened this issue Mar 12, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@blackboxembedded
Copy link

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)
    }
}
@aheze
Copy link
Owner

aheze commented Mar 12, 2023

Hmm... I've come across something similar in testing. It's probably a bug in the library - using the current main branch might fix it.

@simonlasslop
Copy link

I have the same problem. I have added the Menu to a BarButtonItem through custom view.

@bribar
Copy link

bribar commented Mar 12, 2024

I've seen the same issue. Sad this doesn't seem to maintained @aheze ?, good library. I noticed it will work repeated times but it is random touching different parts of the button and sometimes longer presses trigger it. None the less, not good user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants