In my app I have a settings page, and I would like a UIPickerView that works as a check box(lists items and you can enable or disable them). I've looked up different solutions and all I could find was using viewForRow and using UIButton. I am able to add the buttons and it looks good but the buttons don't seem to be tappable.
Heres my implementation:
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView{
let button = UIButton(type: .system)
button.addTarget(self, action: #selector(screenSelectorButtonPress(_:)), for: .touchUpInside)
button.tag = 0
if row == 0{
button.setTitle(Array3[row], for: .normal)
}else{
button.setTitle("\u{2610} \(Array3[row])", for: .normal)
}
return button
}
@objc func screenSelectorButtonPress(_ sender:UIButton!){
print("test")
}
The cells all populate properly but tapping them does nothing. The functionality that I want is exactly as seen here in safari.
Is there another way to do this or am I doing something wrong with the button? Also yes I could just use switches but our Android version of the app uses a check list like how safari does and we would like to keep it consistent.