Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS11 UIBarButtonItem not working

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(_:)))
like image 519
Rajeev Bhatia Avatar asked Mar 09 '23 01:03

Rajeev Bhatia


2 Answers

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!

like image 177
arturh Avatar answered Mar 16 '23 16:03

arturh


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

like image 45
here Avatar answered Mar 16 '23 17:03

here