4

I have an app that is live in the store. I am trying to get it ready for the iOS11 release but have run into an annoying problem.

None of the UIBarButtonItems in the app are working properly. The leftBarButtonItems are clickable but the click area is slightly to the right of the item. The rightBarButtonItems are not working at all! I have added the items both via the storyboard and via code but none of them seem to be working. Please help!

Here's an example:-

navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Save", comment: "save button title"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(VC.rightBarButtonClicked(_:)))
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Rajeev Bhatia
  • 2,974
  • 1
  • 21
  • 29
  • Could you check Safe Area ? Refer - https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area – user1046037 Sep 18 '17 at 13:37

3 Answers3

6

Had the same issue. It came down to an extension on UIButton in a file called "UIButton+MinimumTouchArea.swift" in our project which overrides UIButton.hitTest and breaks UIBarButtonItem in iOS 11. It took us a the whole day to figure out!

arturh
  • 449
  • 5
  • 9
1

iOS11 UIBarButtonItem action not get called

ran into the same, solution for me was to build with xcode 8.3 instead (devices with ios11 running the app build by 8.3 worked great)

Use Xcode 8 with iOS 11 you can use this workaround to debug ios11 devices on xcode 8.3

here
  • 11
  • 1
  • 1
    Thanks for the response. This is what I am doing right now as well but there should be a way to solve this problem with Xcode9 since I made a sample app and downloaded another open source project, both of which work fine – Rajeev Bhatia Sep 21 '17 at 09:23
0

Yes there bug in iOS 11 so you can use another way for it.

Use interactivePopGestureRecognizer like

 self.navigationController?.interactivePopGestureRecognizer?.delegate = self as! UIGestureRecognizerDelegate

and implement delegate method like

 func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        guard gestureRecognizer == interactivePopGestureRecognizer else {
            return true // default value
        }

        // Write you code here.
    }
Govaadiyo
  • 5,644
  • 9
  • 43
  • 72