Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    A deep dive into Apple’s AI strategy reset, as it prepares to announce a Gemini-powered personalized Siri next month and a reimagined chatbot-like Siri at WWDC (Mark Gurman/Bloomberg)

    January 25, 2026

    European Space Agency’s cybersecurity in freefall as yet another breach exposes spacecraft and mission data

    January 25, 2026

    The human brain may work more like AI than anyone expected

    January 25, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – UIBarButtonItem Doesn’t Reset the Badge
    iOS Development

    ios – UIBarButtonItem Doesn’t Reset the Badge

    big tee tech hubBy big tee tech hubSeptember 1, 2025012 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – UIBarButtonItem Doesn’t Reset the Badge
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I’m currently working on integrating new iOS 26 features into my app, and so far, the process has been really exciting. However, I’ve encountered an issue when updating the badge of a UIBarButtonItem, and I’m hoping to get some insights or suggestions.

    The app has two UIViewController instances in the navigation stack, each containing a UIBarButtonItem.

    On the first controller, the badge is set to 1, and on the second, the badge is set to 2. In the second controller, there is a “Reset” button that sets the badge of the second controller to nil.

    However, when I tap the “Reset” button, instead of setting the badge to nil, it sets the value to 1.

    I would appreciate any ideas or suggestions on how to solve this problem. Maybe I am using the badge API incorrectly.

    Thank you!

    class ViewController: UIViewController {
        
        var cartButtonItem: UIBarButtonItem!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            configureNavigationItem()
        }
        
        func configureNavigationItem() {
            cartButtonItem = UIBarButtonItem(image: UIImage(resource: .cartNavBar), style: .plain, target: self, action: #selector(showCart))
            cartButtonItem.tintColor = UIColor.systemBlue
            cartButtonItem.badge = .count(1)
            navigationItem.rightBarButtonItem = cartButtonItem
        }
        
        @objc func showCart() {
            // Add second view controller in navigation stack
            performSegue(withIdentifier: "Cart", sender: nil)
        }
    
    }
    
    class CartViewController: UIViewController {
        
        var cartButtonItem: UIBarButtonItem!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            configureNavigationItem()
        }
        
        func configureNavigationItem() {
            cartButtonItem = UIBarButtonItem(image: UIImage(resource: .cartNavBar), style: .plain, target: nil, action: nil)
            cartButtonItem.tintColor = UIColor.systemBlue
            cartButtonItem.badge = .count(2)
            navigationItem.rightBarButtonItem = cartButtonItem
        }
        
        func updateBadge() {
            cartButtonItem.badge = nil
        }
        
        @IBAction func resetButtonPressed(_ sender: Any) {
            updateBadge()
        }
    
    }
    



    Source link

    Badge doesnt iOS Reset UIBarButtonItem
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    A deep dive into Apple’s AI strategy reset, as it prepares to announce a Gemini-powered personalized Siri next month and a reimagined chatbot-like Siri at WWDC (Mark Gurman/Bloomberg)

    January 25, 2026

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    swift – iOS suspends app after BLE discovery even though I start Always-authorized location udpates

    January 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    A deep dive into Apple’s AI strategy reset, as it prepares to announce a Gemini-powered personalized Siri next month and a reimagined chatbot-like Siri at WWDC (Mark Gurman/Bloomberg)

    January 25, 2026

    European Space Agency’s cybersecurity in freefall as yet another breach exposes spacecraft and mission data

    January 25, 2026

    The human brain may work more like AI than anyone expected

    January 25, 2026

    Non-Abelian anyons: anything but easy

    January 25, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    A deep dive into Apple’s AI strategy reset, as it prepares to announce a Gemini-powered personalized Siri next month and a reimagined chatbot-like Siri at WWDC (Mark Gurman/Bloomberg)

    January 25, 2026

    European Space Agency’s cybersecurity in freefall as yet another breach exposes spacecraft and mission data

    January 25, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.