Quantcast
Channel: Active questions tagged uipickerview - Stack Overflow
Viewing all articles
Browse latest Browse all 592

How to make element in UIPickerView not clickable or "disable" it [duplicate]

$
0
0

This question already has an answer here:

I have a UIPickerView which has lets say 4 Elements in it, now if one element is selected, I want that one Element to not be selectable anymore. I have managed to gray out the already selected ones, however they are still selectable. How can I make these rows not clickable or disable them?

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        if pickerView.tag == 300 {
            if selectedCourseLeads.contains(courseLeads[row]) {
                pickerView.selectRow(row + 1, inComponent: 0, animated: true)
            }
            return courseLeads[row].firstName + " " + courseLeads[row].name
        }
        else {
            return courseHelpers[row].firstName + " " + courseHelpers[row].name
        }
    }

Here the already selected elements are grayed out under the if statement which compares both arrays.


Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>