0

With ios14, apple introduced the UIMenus we know to the navigation bar, so we could go back a couple of screens within a single long tap.

enter image description here

However, I want to remove that behavior from my app.

I tried doing a new class without setting the menu to the UIBarButtonItem and later on adding it to the navigation bar like shown below.

class BackBarButtonItem: UIBarButtonItem {
  @available(iOS 14.0, *)
  override var menu: UIMenu? {
    set {
      /* Don't set the menu here */
      /* super.menu = menu */
    }
    get {
      /* return nil doesn't work either */
      return super.menu
    }
  }
}
let backButton = BackBarButtonItem(title: "BACK", style: .plain, target: nil, action: nil)
navigationItem.backBarButtonItem = backButton

Doesn't work ^^^

navigationItem.backBarButtonItem?.menu = nil // still displays the menu

This didn't seem to work either.

How could I remove that menu?

Jalil
  • 1,167
  • 11
  • 34
  • Why would you want to remove it? – aheze Sep 28 '20 at 17:30
  • We are a fintech, and we need the users to follow a very specific path because of some banks regulations – Jalil Sep 28 '20 at 17:34
  • navigationItem.setLeftBarButtonItems(nil, animated: true) works ? or you can put a new one set nil again , can you try ? – roadRunner Sep 28 '20 at 17:38
  • Someone else's asking the same thing https://stackoverflow.com/a/63964382/14351818 and https://developer.apple.com/forums/thread/653913 but it looks like it's not working for you – aheze Sep 28 '20 at 17:40
  • 1
    @aheze yes, I tried everything they and a bit more in the second link you sent me. I'll keep trying – Jalil Sep 28 '20 at 17:49
  • @sekoya nope, didn't work :/ – Jalil Sep 28 '20 at 17:51

0 Answers0