无法处理右侧 UIBarButtonItem 上的点击
Cannot handle tap on UIBarButtonItem on the right side
我无法处理右侧 UIBarButtonItem 上的点击。
hamburgerView = HamburgerIcon()
hamburgerView.userInteractionEnabled = true
hamburgerView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hamburgerIconClicked)))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: hamburgerView)
但是当我使用左侧的这个按钮时,一切正常。
hamburgerView = HamburgerIcon()
hamburgerView.userInteractionEnabled = true
hamburgerView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hamburgerIconClicked)))
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: hamburgerView)
为 hamburgerView
设置框架已解决问题。
hamburgerView.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
不知道为什么左右不一样
我无法处理右侧 UIBarButtonItem 上的点击。
hamburgerView = HamburgerIcon()
hamburgerView.userInteractionEnabled = true
hamburgerView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hamburgerIconClicked)))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: hamburgerView)
但是当我使用左侧的这个按钮时,一切正常。
hamburgerView = HamburgerIcon()
hamburgerView.userInteractionEnabled = true
hamburgerView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hamburgerIconClicked)))
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: hamburgerView)
为 hamburgerView
设置框架已解决问题。
hamburgerView.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
不知道为什么左右不一样