How do I give a UITextView focus programmatically?

前端 未结 6 1529
[愿得一人]
[愿得一人] 2020-12-25 09:19

So I want to bring in a modal view controller that has a UITextView in it and I want the keyboard to automatically popup and the UITextView have focus.

I found a way

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-25 10:08

    On Xamarin Forms Custom Render:

       protected override void OnElementChanged(ElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
    
            if (Control != null)
            {
                Control.BecomeFirstResponder();
            }
        }
    

提交回复
热议问题