NavigationBar Buttons Click Area not working properly (Image is not clickable)

一曲冷凌霜 提交于 2020-06-12 07:17:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!