问题
Xcode 11.4 - iOS 13.4
Navigation bar UIBarButton items are not working as expected. (I used storyboard for buttons - no code written)
It was working just fine after I updated Xcode. Now it is not working.
Only Green area can be touched. Images can not. I also checked Screen Debugger and everything is seems correct.
There is a question like this but for search bar and push. However, answers not solving my problem.
If you can not figure out how the hell is not working?
You can also check this gif for a similar situation from another stack overflow question.
It is not the same, (no push, or search bar) but "not clickable images" are the same.
回答1:
There are possible 2 solutions that I found so far
1) Downgrade Xcode to 11.3.1 from https://developer.apple.com/download/more/?q=xcode
2) This UIButton extension breaks all the UIBarButtons in Navigation Bar and also in Tool Bar. This is just for my case. You may have same override func that may break.
extension UIButton{
open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
return self.bounds.contains(point) ? self : nil
}
}
来源:https://stackoverflow.com/questions/61278358/navigationbar-buttons-click-area-not-working-properly-image-is-not-clickable