佚名通过本文主要向大家介绍了right mouse button,mouserightbuttondown,right button,tpm rightbutton,rightbutton.png等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 求问navigationItemrightBarButtonItems中的items的隐藏方法
描述:
这是navigation的写法,业务场景有些子类显示搜索,有些不显示,一开始的思路是在子类里面复写这个方法覆盖父类的方法,然并卵,debug看的时候,父类的这个方法会执行,子类的方法也会执行,就是覆盖不了,求问大神有没有做过类似的思路的
解决方案1:
描述:
let listBtn = UIButton.init(type: .custom)
listBtn.frame = CGRect.init(x: 0, y: 0, width: dp(px: 12), height: dp(px: 14))
listBtn.setBackgroundImage(UIImage.init(named: "prepare_list"), for: .normal)
listBtn.addTarget(self, action: #selector(openStepList), for: .touchUpInside)
let item = UIBarButtonItem.init(customView: listBtn)
searchBtn.frame = CGRect.init(x: 0, y: 0, width: dp(px: 14), height: dp(px: 14))
searchBtn.setBackgroundImage(UIImage.init(named: "search"), for: .normal)
searchBtn.addTarget(self, action: #selector(FlightSafetyNoticeViewController.openSearchVc), for: .touchUpInside)
searchBtn.isHidden = true
//
let whiteBtn = UIButton()
whiteBtn.frame = CGRect.init(x: 0, y: 0, width: dp(px: 12), height: dp(px: 14))
let item2 = UIBarButtonItem.init(customView: searchBtn)
let item3 = UIBarButtonItem.init(customView: whiteBtn)
let items = [item,item3,item2]
self.navigationItem.rightBarButtonItems = items
这是navigation的写法,业务场景有些子类显示搜索,有些不显示,一开始的思路是在子类里面复写这个方法覆盖父类的方法,然并卵,debug看的时候,父类的这个方法会执行,子类的方法也会执行,就是覆盖不了,求问大神有没有做过类似的思路的
解决方案1:
从这部分代码看,是没啥问题的。看看是不是其他地方引的问题。
或者贴出更多的代码看看