Have you initialized _textField ? Like _textField = new UIKit.UITextField(); . Because all fields are nullified when the class is created. After creating ViewController1 or ViewController2 , _textField is null unless you assign it something in the constructor.
More precisely, each T field initialized to default(T) , which is null for reference types.
Btw: Your βfieldβ is a property. But the same is true for auto-properties.
You can initialize _textField like this in the constructor:
public partial class ViewController1 { public ViewController1 (IntPtr handle) : base(handle) { _textField = new UIKit.UITextField(); } }
I must admit that I do not know hamarin. You need to call something like InitializeComponent(); inside the constructor? Does the ViewController1.designer.cs method have a method called so?
public ViewController1 (IntPtr handle) : base(handle) { InitializeComponent(); }
In WinForms, for example, a partial constructor class has a method that creates controls.
source share