简体   繁体   中英

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

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.

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
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM