问题
i'm trying to implement the OTC into my app. I'm doing the next:
_txtField = new UITextField()
{
UserInteractionEnabled = true,
TextContentType = UITextContentType.OneTimeCode
};
_txtFieldDelegate = new UITextFieldDelegate();
_txtField.Delegate = _txtFieldDelegate;
I got the SMS, but i have nothing to fill the TextField, what more i need to get this works?
回答1:
Firstly,OneTimeCode
is available after iOS 12.0.So,add the following code
if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
_txtField.TextContentType = UITextContentType.OneTimeCode;
}
And set the textField as BecomeFirstResponder
after you send the request of get SMS.
_txtField.BecomeFirstResponder();
Then the SMS code will appear on the keyboard.And it will auto fill when you click it.
来源:https://stackoverflow.com/questions/53266952/uitextcontenttype-onetimecode-in-xamarin-ios