We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

read a SfPicker on iOS

I have a little worry I have seen late.
I start and I think to check what I code on Android, but I will probably go too fast for iOS, so I took a little time before I picked up the error:
my SfPicker works well on iOS (although I will have to change the default selection, but that's another story), but when I want to read the selected item, it's a mistake.

Note that this problem does not appear on Android.

3 Replies

FL FLecointe September 12, 2017 08:20 AM UTC

I forgot to specify: in exception, this tells me "Object reference not defined at the instance of an object"

FL FLecointe September 12, 2017 12:27 PM UTC

Well, I ended up finding how to reset the SelectedItem of the picker:
first of all I make sure of the position of the picker:

PickerMoment.SelectedIndex = 0;

Now that I know the value displayed, I manually initialize the selectedItem (which is rather unusual). As I know the initial value this is not a problem.

PickerMoment.SelectedItem = "Indifferent";

what is surprising is that Android has no initialization concerns, it can directly read the selected item, for iOS the selected item is only initialized if its value changes during use ( in other words, by default the selected item does not initialize, but if you swipe on the next or previous iOS initializes the item)

ET Eswaran Thirugnanasambandam Syncfusion Team September 12, 2017 01:39 PM UTC

Hi Flecointe,

Thanks for contacting Syncfusion Support.

We have prepared a sample in which we have used the OkButtonClicked event to display the selected item in the alert dialog box. We are facing an issue while we tried to get the default selected item from the SfPicker when clicking the ok button without altering the picker values. Please check whether this is issue which you are facing from your side. And please find the sample in the below link.

Link: http://www.syncfusion.com/downloads/support/forum/132587/ze/PickerSample1-1834601586

Click the button
In the SfPicker, without changing the selected item. Click “ok”.


Eswaran AT.   

Live Chat Icon For mobile
Up arrow icon