0

I'm having a lot of trouble trying to control the scroll position of a custom iOS Xamarin Editor (UITextView) enclosed in a custom ScrollView (UIScrollView).

The soft keyboard will throw multiple scroll method calls at these controls which result in a huge amount of unpredictable behaviour.

I've read some good discussions about how to decouple the soft keyboard and editor controls but the context is for native iPhone development.

Some of the solutions involve subclassing UITextView and UIScrollView.

My problem is, while I can subclass UIScrollView, because ScrollViewRenderer directly descends from UIScrollView, I can't do so for UITextView, because EditorRenderer only contains a UITextView control.

My question is: is it possible to write an Editor renderer where I can use my own subclassed version of UITextView? The subclass would allow me to override a lot of the behaviour that is causing me so many problems.

jho
  • 199
  • 1
  • 8

1 Answers1

0

I believe I've found my answer.

EditorRenderer has this method which I can override to return MyOwnUITextView which I have derived from a UITextView:

public partial class MyOwnUITextView : UITextView
{
    public int TestInt = 5;
    public MyOwnUITextView() : base()
    {

    }
}

class MyOwnEditorRenderer : EditorRenderer
{
    ...
    ...
    protected override UITextView CreateNativeControl()
    {
        return new MyOwnUITextView();

  
        //return base.CreateNativeControl();
    }
}

This correctly is coming through in my OnElementChanged method.

jho
  • 199
  • 1
  • 8