Unselected UIPickerView value

According to the documentation, if the UIPickerView does not have the selected value, the expected return from the selected RowInComponent: should be:

"Zero-indexed number identifying the selected row, or -1 if no row is selected."

However, if I check the value of the string itself after initialization, its value is 0. Even if I manually set it to -1, it still returns 0. I would like to be able to determine whether the user has selected the value yet or not, without writing its into a local variable. Is it possible?

Example:

UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 46.0, 320.0, 216.0)];
[picker selectRow:-1 inComponent:0 animated:NO];
NSLog(@"SELECTED %d", [picker selectedRowInComponent:0]);

expected output:
SELECTED -1

actual output:
SELECTED 0
+3
source share
1 answer

, , -1, . , UIPickerView. , - , 0, UIPickerView .

+3

Source: https://habr.com/ru/post/1737067/


All Articles