iOS designer - text changed and did begin event issues

GaganSinghGaganSingh USUniversity ✭✭✭

Hi, So I was having some issues with the editing changed and did begin events.

I click on a button which automagically enters text into a text field.
Once theres text in the text field, it should automagically run the editing changed or did begin events.
However, the events aren't launching until i click on the text field.

Is there any way to work around this?

Thank you!

Posts

  • DaveHuntDaveHunt USMember ✭✭✭✭✭
    edited July 2013

    As of IOS6, EditingChanged doesn't seem to fire on SetText. I believe it will still fire if you use InsertText instead. Try setting textField.Text to an empty string, then calling textField.InsertText() to actually set the text. That should cause EditingChanged to fire.

    Not sure if that will also cause did begin events to fire.

  • GaganSinghGaganSingh USUniversity ✭✭✭

    That causes it to only work if I click the text field and then click on the button that calls textField.InsertText().

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Well, those events are really intended for manual input validation. Code that automatically sets a text field shouldn't need the text it sets to be validated. I would recommend doing whatever you need to do in the code that sets the text. Or you could fire the events programatically from your button click handler.

  • GaganSinghGaganSingh USUniversity ✭✭✭

    Ok, ill figure something out. It worked on Xamarin.android, so i assumed it would work the same on Xamarin.iOS.

    I'm actually going to use it with a barcode scanner, so i was just testing it with a button for now.
    Ill see how that work out. Only reason I was doing it this way was because the text field actually gets covered by the keyboard when its clicked. And I didnt know how to handle that. I saw some Obj C examples, but couldnt really follow them.

Sign In or Register to comment.