NavigationBar按钮的单击区域无法正常工作(图像不可单击) [英] NavigationBar Buttons Click Area not working properly (Image is not clickable)

查看:182
本文介绍了NavigationBar按钮的单击区域无法正常工作(图像不可单击)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode 11.4-iOS 13.4

Xcode 11.4 - iOS 13.4

导航栏UIBarButton项无法正常工作. (我将情节提要用于按钮-无需编写代码)

Navigation bar UIBarButton items are not working as expected. (I used storyboard for buttons - no code written)

更新Xcode后,它的工作正常.现在不起作用.

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?

您还可以检查此gif ,以了解来自另一个堆栈溢出问题的类似情况.

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.

推荐答案

到目前为止,我发现了2种可能的解决方案

There are possible 2 solutions that I found so far

1)将Xcode从降级到11.3.1 https://developer.apple.com/download/more/?q=xcode

1) Downgrade Xcode to 11.3.1 from https://developer.apple.com/download/more/?q=xcode

2)此UIButton扩展中断了导航栏和工具栏中的所有UIBarButton.这只是我的情况.您可能具有可能会破坏的相同替代功能.

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

这篇关于NavigationBar按钮的单击区域无法正常工作(图像不可单击)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆