我需要帮助。我正在使用一个按钮,它将取消选择但未按OkButton的过滤器。
@IBAction func cancelBtn(_ sender: Any) {
self.popOver.removeFromSuperview()
}
@IBAction func OkBtn(_ sender: Any) {
self.tbView.reloadData()
self.popOver.removeFromSuperview()
}
在popOverView中,我有2个按钮,onestarButton和twostarButton 选中星形按钮后,它将更改其图像,而按OkBtn时,它将重新加载表格视图
这里是事情,按下OkBtn然后按下filterSelectButton,无论我更改starButton的状态如何,但是当下次按下cancelButton时,都按下filterSelectButton时,它将显示我选择的当前过滤器。
// stars button
@IBAction func oneTapped(_ sender: Any) {
if onestarBtn.isSelected{
onestarBtn.setBackgroundImage(#imageLiteral(resourceName: "1star"), for: .normal)
filteredArray.removeAll(){$0.star == 1}
}else {
onestarBtn.setBackgroundImage(#imageLiteral(resourceName: "1stared"), for: .normal)
filteredArray += oneStarArray
}
onestarBtn.isSelected = !onestarBtn.isSelected
}
@IBAction func twoTapped(_ sender: Any) {
if twostarBtn.isSelected{
twostarBtn.setBackgroundImage(#imageLiteral(resourceName: "2star"), for: .normal)
filteredArray.removeAll(){$0.star == 2}
}else {
twostarBtn.setBackgroundImage(#imageLiteral(resourceName: "2stared"), for: .normal)
filteredArray += twoStarArray
}
twostarBtn.isSelected = !twostarBtn.isSelected
}
谢谢