UITextContentType.OneTimeCode in Xamarin iOS

霸气de小男生 提交于 2021-01-29 08:19:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!