Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Change UITextField on each char.

PrashantRamiPrashantRami USUniversity ✭✭

I want to get PIN number from user. I want 4 different TextField for each Character. and only 1 char allowed in each. after 1 char focus should be move to next TextField automatically.

Answers

  • MabroukMabrouk USMember ✭✭✭

    Hello friend, @PrashantRami ,

    I have something for you :
    You can draw your 4 fiels named for example : pin_x ; where x=1,2,3.

    then, set your change events for your fields (I think the last field dont need that) like :

    pin_x.Changed+= pin_x_TextChanged();

    void pin_x_TextChanged (object sender, EventArgs e)
    {
    if(pin_x?.Text?.Length==1)
        pin_(x+1).BecomeFirstResponder(); // Sets focus
    }
    

    I hope that helps,
    Mabrouk Mahdhi.
    www.mahdhi.com

  • PrashantRamiPrashantRami USUniversity ✭✭

    there is no event called UITextField.Changed. i tried

    Pin0.ValueChanged += Pin0_ValueChanged;
    
    private void Pin0_ValueChanged(object sender, EventArgs e)
            {
                if(Pin0.Text.Length>=1)
                {
                    Pin1.BecomeFirstResponder();
                }
            }
    
Sign In or Register to comment.